第8講設(shè)計(jì)與代碼映射_第1頁
第8講設(shè)計(jì)與代碼映射_第2頁
第8講設(shè)計(jì)與代碼映射_第3頁
第8講設(shè)計(jì)與代碼映射_第4頁
第8講設(shè)計(jì)與代碼映射_第5頁
已閱讀5頁,還剩53頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-82w可見性可見性w設(shè)計(jì)類圖設(shè)計(jì)類圖w代碼映射代碼映射w測(cè)試驅(qū)動(dòng)開發(fā)與代碼重構(gòu)測(cè)試驅(qū)動(dòng)開發(fā)與代碼重構(gòu)上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-84w確定四種可見性確定四種可見性w對(duì)設(shè)置可見性進(jìn)行設(shè)計(jì)對(duì)設(shè)置可見性進(jìn)行設(shè)計(jì)上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-85w可見性可見性Visibility 是對(duì)象看到或引用其它對(duì)象的是對(duì)象看到或引用

2、其它對(duì)象的能力能力w為了使發(fā)送者對(duì)象能夠向接收者對(duì)象發(fā)送消息,為了使發(fā)送者對(duì)象能夠向接收者對(duì)象發(fā)送消息,發(fā)送者必須具有接收者的可見性,即發(fā)送者必須發(fā)送者必須具有接收者的可見性,即發(fā)送者必須擁有對(duì)接收者對(duì)象的某種引用或指針擁有對(duì)接收者對(duì)象的某種引用或指針上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-86: RegisterenterItem(itemID, quantity): ProductCatalogspec := getSpecification( itemID )public void enterItem( itemID, qty ) . spec = ca

3、talog.getSpecification(itemID) .class Register . private ProductCatalog catalog; .上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-87w實(shí)現(xiàn)對(duì)象實(shí)現(xiàn)對(duì)象A到對(duì)象到對(duì)象B的可見性通常有四種方式的可見性通常有四種方式:n屬性可見性屬性可見性Attribute Visibility: B是是A的屬性的屬性n參數(shù)可見性參數(shù)可見性Parameter visibility: B是是A方法中的參數(shù)方法中的參數(shù)n局部可見性局部可見性Local Visibility: B是是A中方法的局部對(duì)象中方法的局部

4、對(duì)象(不是參數(shù))(不是參數(shù))n全局可見性全局可見性Global Visibility: B具有某種方式的全局可具有某種方式的全局可見性見性w為了使對(duì)象為了使對(duì)象A能夠向?qū)ο竽軌蛳驅(qū)ο驜發(fā)送消息,對(duì)于發(fā)送消息,對(duì)于A而而言,言,B必須是可見的必須是可見的上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-88w這是一種相對(duì)持久地可見性這是一種相對(duì)持久地可見性: RegisterenterItem(itemID, quantity): ProductCatalogspec := getSpecification( itemID )public void enterItem(i

5、temID, qty) . spec = catalog.getSpecification(itemID) .class Register . private ProductCatalog catalog; .上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-89w這是一種相對(duì)暫時(shí)的可見性這是一種相對(duì)暫時(shí)的可見性2: makeLineItem(spec, qty)enterItem(id, qty)1: spec := getSpecification(id)2.1: create(spec, qty):Register:Sale:ProductCatalogsl :

6、SalesLineItemmakeLineItem(ProductSpecification spec, int qty) . sl = new SalesLineItem(spec, qty); .上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-810w將參數(shù)可見性轉(zhuǎn)化為屬性可見性十分常見將參數(shù)可見性轉(zhuǎn)化為屬性可見性十分常見2: makeLineItem(spec, qty)enterItem(id, qty)2: spec := getSpecification(id)2.1: create(spec, qty):Register:Sale:ProductCata

7、logsl : SalesLineItem/ initializing method (e.g., a Java constructor)SalesLineItem(ProductSpecification spec, int qty).productSpec = spec; / parameter to attribute visibility.上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-811w實(shí)現(xiàn)局部可見性的兩種常見方式實(shí)現(xiàn)局部可見性的兩種常見方式:n創(chuàng)建新的局部實(shí)例并將其分配給局部變量創(chuàng)建新的局部實(shí)例并將其分配給局部變量n將方法調(diào)用返回的對(duì)象分配給局部變量

8、將方法調(diào)用返回的對(duì)象分配給局部變量: RegisterenterItem(itemID, quantity): ProductCatalogspec := getSpecification( itemID )enterItem(id, qty)./ local visibility via assignment of returning objectProductSpecification spec = catalog.getSpecification(id);.上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-812w這是一種相對(duì)持久的可見性這是一種相對(duì)持久的可見性w

9、將實(shí)例分配給全局變量,這在某些語言如將實(shí)例分配給全局變量,這在某些語言如C+中中是可能的是可能的上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-813:A:B1: msg():C2: msg():D3: msg():E4: msg()is used forattribute visibility上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-815w交互圖完成后,有可能來定義軟件類(接口)的交互圖完成后,有可能來定義軟件類(接口)的描述描述w設(shè)計(jì)類圖(設(shè)計(jì)類圖(Design Clas

10、s Diagrams,DCD)上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-816w實(shí)踐中,交互圖經(jīng)常與實(shí)踐中,交互圖經(jīng)常與DCD并行創(chuàng)建并行創(chuàng)建w為了更清楚地說明為了更清楚地說明DCD,我們選擇了在交互圖,我們選擇了在交互圖之后介紹之后介紹DCD上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-817RegisterenterItem(.)SaledateisComplete : BooleantimemakeLineItem(.)CapturesNavigability11Three section box forclass defini

11、tion.methods; there are parameters, but unspecifiedtype information上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-818w設(shè)計(jì)類圖描述了應(yīng)用中的軟件類和接口設(shè)計(jì)類圖描述了應(yīng)用中的軟件類和接口n類,關(guān)聯(lián)和屬性類,關(guān)聯(lián)和屬性n接口,包括操作和常量接口,包括操作和常量n方法方法n屬性類型信息屬性類型信息n可見性可見性n依賴依賴wUP并沒有專門的并沒有專門的 “設(shè)計(jì)類圖設(shè)計(jì)類圖”wUP定義了設(shè)計(jì)模型,包括交互,包和類圖定義了設(shè)計(jì)模型,包括交互,包和類圖.w在在UP設(shè)計(jì)模型中的類圖包含設(shè)計(jì)模型中的類圖包含“設(shè)計(jì)

12、類設(shè)計(jì)類”上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-819Register.endSale()enterItem(.)makePayment(.)SaledateisComplete : BooleantimemakeLineItem(.)CapturesRegisterSaledateisComplete : BooleantimeCapturessoftware class1111Domain ModelDesign ModelConcept; conceptual class上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-820w

13、確定軟件類并展示它們確定軟件類并展示它們n檢查交互圖并列出提到的所有類檢查交互圖并列出提到的所有類RegisterSaleProductCatalogProductSpecificationStoreSalesLineItemPayment上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-821w給這些類畫類圖,列出通過領(lǐng)域模型中識(shí)別出來,給這些類畫類圖,列出通過領(lǐng)域模型中識(shí)別出來,并在設(shè)計(jì)中采用的屬性并在設(shè)計(jì)中采用的屬性Register.SaledateisCompletetime.SalesLineItemquantity.ProductCatalog.Produc

14、tSpecificationdescriptionpriceitemID.Storeaddressname.Paymentamount.The Cashier is not present in the design since for the current iteration it is not necessary to model it in software.上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-822w添加方法名添加方法名n通過分析交互圖,每一個(gè)類具有的方法可以確定通過分析交互圖,每一個(gè)類具有的方法可以確定:Register:Sale2: make

15、LineItem(spec, qty)Sale.makeLineItem(.)上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-823SalesLineItem- quantity+ getSubtotal()ProductCatalog.+ getSpecification(.)ProductSpecification- description- price- itemID.Store- address- name+ addSale(.)Payment- amount.Register.+ endSale()+ enterItem(.)+ makeNewSale()+

16、 makePayment(.)Sale- date- isComplete- time+ becomeComplete()+ makeLineItem(.)+ makePayment(.)+ getTotal()上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-824w一些注意點(diǎn)一些注意點(diǎn)ncreate 消息的解釋消息的解釋n訪問方法訪問方法n多對(duì)象消息多對(duì)象消息n與語言無關(guān)的語法與語言無關(guān)的語法上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-825w每一種語言有各自特定的實(shí)例化每一種語言有各自特定的實(shí)例化instantiation或或者初始化

17、者初始化initialization的方法的方法n在在C+, 它包含了通過跟隨一個(gè)構(gòu)造函數(shù)的它包含了通過跟隨一個(gè)構(gòu)造函數(shù)的new操作進(jìn)操作進(jìn)行自動(dòng)內(nèi)存分配行自動(dòng)內(nèi)存分配n在在Java中中, 它包含了對(duì)它包含了對(duì)new 運(yùn)算符的調(diào)用,后面跟構(gòu)運(yùn)算符的調(diào)用,后面跟構(gòu)造函數(shù)調(diào)用造函數(shù)調(diào)用上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-826w獲取或者設(shè)置屬性獲取或者設(shè)置屬性n我們可以將所有屬性定義為私有,并對(duì)它們定義我們可以將所有屬性定義為私有,并對(duì)它們定義accessor和和mutatorw這些方法一般在類圖中不顯示這些方法一般在類圖中不顯示-上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程

18、系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-827w給多對(duì)象的消息一般解釋為發(fā)送給一個(gè)給多對(duì)象的消息一般解釋為發(fā)送給一個(gè)container/collection 對(duì)象,例如對(duì)象,例如 Java Map, a C+ map 或者或者Smalltalk Dictionary1: spec := getSpecification(id)1.1: spec := find(id):ProductCatalog:ProductSpecificationThe find message is to thecontainer object, not to aProductSpecification.上海交

19、通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-828w屬性,方法參數(shù)和返回值的類型可以有選擇的顯屬性,方法參數(shù)和返回值的類型可以有選擇的顯示示w什么時(shí)候顯示什么時(shí)候顯示? 取決于取決于n目的目的: Code Generation or only Read上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-829SalesLineItemquantity : IntegergetSubtotal() : MoneyProductCatalog.getSpecification(id: ItemID) : ProductSpecificationProd

20、uctSpecificationdescription : Textprice : MoneyitemID : ItemID.Storeaddress : Addressname : TextaddSale(s : Sale)Paymentamount : Money.Register.endSale()enterItem(id : ItemID, qty : Integer)makeNewSale()makePayment(cashTendered : Money)Saledate : DateisComplete : Booleantime : TimebecomeComplete()ma

21、keLineItem(spec : ProdSpecification , qty : Integer)makePayment(cashTendered : Money)getTotal() : MoneyReturn type of methodvoid; no return value上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-830w關(guān)聯(lián)的每一端稱為一個(gè)角色,在關(guān)聯(lián)的每一端稱為一個(gè)角色,在DCD中,角色中,角色可以用方向箭頭修飾可以用方向箭頭修飾上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-831CapturesRegisterc

22、urrentSale : SaleendSale()enterItem(.)makeNewSale()makePayment(.)SaledateisCompletetimebecomeComplete()makeLineItem(.)makePayment(.)getTotal()Navigability arrow indicatesRegister objects are connecteduni-directionally to Saleobjects.Absence of navigabilityarrow indicates noconnection from Sale toReg

23、ister.Register class willhave an attribute pointing to aSale object.11the currentSaleattribute is oftenexcluded, as it isimplied by thenavigableassociation fromRegister to Sale.上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-832w關(guān)聯(lián)上的方向箭頭一般解釋為從源到目標(biāo)類的屬關(guān)聯(lián)上的方向箭頭一般解釋為從源到目標(biāo)類的屬性可見性性可見性w在在OOP中中, 它一般被實(shí)現(xiàn)為源類中有一個(gè)指向目它一般被實(shí)現(xiàn)

24、為源類中有一個(gè)指向目標(biāo)類對(duì)象的屬性標(biāo)類對(duì)象的屬性上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-833w一些需要定義從一些需要定義從A指向指向B的方向性修飾的情形的方向性修飾的情形:nA發(fā)送消息給發(fā)送消息給BnA創(chuàng)建創(chuàng)建B的實(shí)例的實(shí)例nA 需要保持與需要保持與B的連接的連接上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-834w方向性方向性Navigability 通過交互圖來識(shí)別通過交互圖來識(shí)別i:Store:Registerpc:ProductCatalogcreate()2: create(pc)1: create()1.2: load

25、ProdSpecs():ProductSpecification1.1: create()1.2.2*: add(ps)1.2.1*: create(id, price, description)ps:ProductSpecification上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-835SalesLineItemquantity : IntegergetSubtotal()ProductCatalog.getSpecification(.)ProductSpecificationdescription : Textprice : MoneyitemID : I

26、temID.Storeaddress : Addressname : TextaddSale(.)Paymentamount : Money.Contains1.*Contains1.*RegisterendSale()enterItem(.)makeNewSale()makePayment(.)Saledate : DateisComplete : Booleantime : TimebecomeComplete()makeLineItem(.)makePayment(.)getTotal()CapturesHousesUsesLooks-inPaid-byDescribes11111111

27、11111*Logs-completed4*1上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-836w依賴關(guān)系表明一個(gè)元素(包括類,用例,等等)依賴關(guān)系表明一個(gè)元素(包括類,用例,等等)知道另外一個(gè)元素知道另外一個(gè)元素n用虛線箭頭表示用虛線箭頭表示w在類圖中,依賴關(guān)系可以表示非屬性可見性,即:在類圖中,依賴關(guān)系可以表示非屬性可見性,即:參數(shù),全局或者局部可見性參數(shù),全局或者局部可見性上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-837SalesLineItemquantity : IntegergetSubtotal()ProductCat

28、alog.getSpecification(.)ProductSpecificationdescription : Textprice : MoneyitemID: ItemID.Storeaddress : Addressname : TextaddSale(.)Paymentamount : Money.Contains1.*Contains1.*Register.endSale()enterItem(.)makeNewSale()makePayment(.)Saledate : DateisComplete : Booleantime : TimebecomeComplete()make

29、LineItem(.)makePayment(.)getTotal()CapturesHousesUsesLooks-inPaid-byDescribes1111111111111*A dependency of Register knowing aboutProductSpecification.Recommended when there is parameter,global or locally declared visibility.Logs-completed4*1上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-838SampleClassclassAtt

30、ribute+ publicAttribute- privateAttributeattributeWithVisibilityUnspecifiedattribute1 : typeburgers : List of VeggieBurgerattribute2 : type = initial valuefinalConstantAttribute : int = 5 frozen /derivedAttributeclassMethod()+ 玞onstructor?SampleClass(int)methodWithVisibilityUnspecified()methodReturn

31、sSomething() : FooabstractMethod()abstractMethod2() abstract / alternate+ publicMethod()- privateMethod()# protectedMethod() packageVisibleMethod()finalMethod() leaf methodWithoutSideEffects() query synchronizedMethod() guarded method1WithParms(in parm1:String, inout parm2:int)method2WithParms(parm1

32、:String, parm2:float)method3WithParms(parm1, parm2)method4WithParms(String, int)methodWithParmsAndReturn(parm1: String) : FoomethodWithParmsButUnspecified(.) : FoomethodWithParmsAndReturnBothUnspecified()java.awt.Fontplain : Integer = 0 frozen bold : Integer = 1 frozen name : Stringstyle : Integer =

33、 0.+ getFont(name : String) : Font+ getName() : String.java.awt.Toolkitorjava.awt.Toolkit abstract . / there are attributes, but not shown# createButton(target : Button) : ButtonPeer+ getColorModel() : ColorModel.FinalClass leaf . / there are methods, but not shown玦nterface粆Runnablerun()AlarmClockru

34、n().an emptycompartmentwithout ellipsismeans there isdefinitely nomembers (inthis case, noattributes)上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-839Register.endSale()enterItem(id, qty)makeNewSale()makePayment(cashTendered) ProductSpecification spec = catalog.getSpecification(id); sale.makeLineItem(spec, qt

35、y);public void enterItem( id, qty ) ProductSpecification spec = catalog.getSpecification(id); sale.makeLineItem(spec, qty);UML notation:A method body implementation may be shown in a UML note box. It should be placed within braces, whichsignifies it is semantic influence (it is more than just a comm

36、ent).The synax may be pseudo-code, or any language.It is common to exclude the method signature (public void .), but it is legal to include it.上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-840Register. . .Saledate. . .1. . . . .Domain ModelUse-Case ModelDesign Model: RegisterenterItem(itemID, quantity): Prod

37、uctCatalogspec := getSpecification( itemID ). . .inspiresthe namesandattributesof somesoftwareclasses inthe designmakeNewSale()Sample UP Artifact Relationships for Design Class DiagramsRegister.makeNewSale()enterItem(.).ProductCatalog.getSpecification(.).1*. . . . . . .1Saledate.use-caserealizations

38、(UCRs)designclassdiagrams(DCDs)the design classesdiscovered whiledesigning UCRs aresummarized in DCDsrequires UCRssuggests domainconcepts上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-842w交互圖和交互圖和DCD可以作為代碼生成過程的輸入可以作為代碼生成過程的輸入w實(shí)現(xiàn)模型包括源代碼,數(shù)據(jù)庫定義,源代碼,實(shí)現(xiàn)模型包括源代碼,數(shù)據(jù)庫定義,源代碼, JSP/XML/HTML上

39、海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-843w現(xiàn)代方法現(xiàn)代方法: Design-while-programmingw但是我們經(jīng)常在編程前進(jìn)行可視化建模但是我們經(jīng)常在編程前進(jìn)行可視化建模上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-844w設(shè)計(jì)中也包括決策和創(chuàng)新工作設(shè)計(jì)中也包括決策和創(chuàng)新工作w代碼的生成代碼的生成 = 機(jī)械翻譯過程機(jī)械翻譯過程?n不完全對(duì)不完全對(duì)n需要修改,詳細(xì)的問題將出現(xiàn)并被解決需要修改,詳細(xì)的問題將出現(xiàn)并被解決上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-845RequirementsA

40、nalysisDesignImplementationand TestingIterative Cyclesof DevelopmentRequirementsAnalysisDesignImplementationand TestingRequirementsAnalysisDesignImplementationand TestingTime上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-847public class SalesLineItemprivate int quantity;public Sa

41、lesLineItem(ProductSpecification spec, int qty) . public Money getSubtotal() . SalesLineItemquantity : IntegergetSubtotal() : MoneyProductSpecificationdescription : Textprice : MoneyitemID : ItemID.Described-by1*It is derived from the create(spec, qty) message sent to a SalesLineItem上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上

42、海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-848w類的引用屬性是依據(jù)類圖中的關(guān)聯(lián)和方向性來的類的引用屬性是依據(jù)類圖中的關(guān)聯(lián)和方向性來的SalesLineItemquantity : IntegergetSubtotal() : MoneyProductSpecificationdescription : Textprice : MoneyitemID : ItemID.Described-bypublic class SalesLineItemprivate int quantity;private ProductSpecification productSpec;public SalesLi

43、neItem(ProductSpecification spec, int qty) . public Money getSubtotal() . *1Simple attributeReference attribute上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-849w角色名字是角色的標(biāo)識(shí)角色名字是角色的標(biāo)識(shí)SalesLineItemquantity : IntegergetSubtotal() : MoneyProductSpecificationdescription : Textprice : MoneyitemID : ItemID.Described

44、-bypublic class SalesLineItem.private int quantity;private ProductSpecification productSpec;productSpecRole name used inattribute name.*1上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-850Saledate : DateisComplete : Booleantime : TimebecomeComplete()makeLineItem()makePayment()getTtotal()public class Saleprivat

45、e Date dateTime = new Date();.In Java, the java.util.Date class combines both dateand timestamp information. Therefore, the separateattributes in the design can be collapsed when mappingto Java.上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-851w消息的順序被翻譯成方法定義中的一系列聲明消息的順序被翻譯成方法定義中的一系列聲明2: makeLineItem(spec, qty

46、)enterItem(id, qty)1: spec := getSpecification(id)2.1: create(spec, qty)1.1: spec := find(id):Register:Sale:ProductCatalogsl: SalesLineItemSalesLineItem:SalesLineItem:ProductSpecification2.2: add(sl)上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系上海交通大學(xué)計(jì)算機(jī)科學(xué)與工程系2022-3-852ProductCatalog.getSpecification(.)Saledate : DateisComplete : Booleantime : TimebecomeComplete()mak

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論