文稿軟件開(kāi)發(fā)2015_第1頁(yè)
文稿軟件開(kāi)發(fā)2015_第2頁(yè)
文稿軟件開(kāi)發(fā)2015_第3頁(yè)
文稿軟件開(kāi)發(fā)2015_第4頁(yè)
文稿軟件開(kāi)發(fā)2015_第5頁(yè)
已閱讀5頁(yè),還剩33頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

1、Chap 17 Design Model: Use-case Realizations With GRASP PatternsObjectives Design use-case realizations. Apply the GRASP patterns to assign responsibilities to classes. Use the UML interaction diagram notation to illustrate the design of objects.2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程回顧GRASP設(shè)計(jì)模式: (1)信息專家把職責(zé)分配給信息專

2、家 (2)創(chuàng)建者把創(chuàng)建類A實(shí)例的職責(zé)分配給類B,IF (3)低耦合分配職責(zé)時(shí)要保持低耦合 (4)高內(nèi)聚分配職責(zé)時(shí)要保持高內(nèi)聚 (5)控制者接收和處理系統(tǒng)事件消息的職責(zé)分配給 控制者.2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程模式運(yùn)用常識(shí)除非是控制器或創(chuàng)建者問(wèn)題,信息專家模式是我們應(yīng)該第一考慮采用的模式. 再利用低耦合和高內(nèi)聚進(jìn)行優(yōu)化設(shè)計(jì).2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程職責(zé)分配和對(duì)象協(xié)作設(shè)計(jì)是設(shè)計(jì)中非常重要和創(chuàng)造性的步驟,無(wú)論是繪制各種圖或編碼時(shí)都是如此。2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程Use Case RealizationsA “use c

3、ase realization”描述如何在對(duì)象設(shè)計(jì)中用“協(xié)作對(duì)象(collaborating objects)”來(lái)實(shí)現(xiàn)某個(gè)特定用例. RUP用例實(shí)現(xiàn)反映“用例表現(xiàn)的需求與滿足需求的對(duì)象設(shè)計(jì)之間的關(guān)系”.The interaction diagrams are a common language to illustrate use case realizations.2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程Use Case RealizationsThe system events (suggested by the use case) represent messages that

4、 initiate interaction diagrams. E.g.Process Sale system events are: makeNewSale, enterItem, endSale, makePayment. We will have an interaction diagram for each of them.用例-用例場(chǎng)景-系統(tǒng)事件2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程Object Design: makeNewSale顧客攜帶欲購(gòu)商品到達(dá)收銀處,收銀員請(qǐng)求開(kāi)始一次新的銷售,于是makeNewSale系統(tǒng)

5、操作發(fā)生.2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程makeNewSale選擇控制器類 第一個(gè)設(shè)計(jì)選擇是為系統(tǒng)操作消息makeNewSale挑選控制類. 根據(jù)Controller模式有下面的選擇:2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程makeNewSale如果只存在一定數(shù)量的系統(tǒng)事件,選擇一個(gè)(如Register)外觀控制器就可以滿足要求,外觀控制器不需要承擔(dān)過(guò)多的職責(zé).當(dāng)存在許多系統(tǒng)操作,而且我們希望職責(zé)分配分散分布,以保證每一個(gè)控制器輕量和集中時(shí),選擇用例控制器是合適的.本例中,選擇Register就足夠了,下圖所示的交互圖從發(fā)送makeNewSale消息到Regi

6、ster軟件對(duì)象開(kāi)始.2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程makeNewSale2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程makeNewSale創(chuàng)建一次新銷售選擇了Register作為接收和處理系統(tǒng)事件消息makeNewSale的控制器后,必須要?jiǎng)?chuàng)建Sale軟件對(duì)象以處理實(shí)際的銷售,根據(jù)GRASP創(chuàng)建者模式,應(yīng)將創(chuàng)建對(duì)象的職責(zé)分配給一個(gè)類,這個(gè)類聚集、包含或記錄要被創(chuàng)建的對(duì)象。通過(guò)分析領(lǐng)域模型,我們選擇Register作為創(chuàng)建Sale 的合理候選者。創(chuàng)建Sale時(shí),必須創(chuàng)建一個(gè)空的集合(容器,如Java的List)以記錄未來(lái)可能加入的SalesLineItem實(shí)例。2

7、022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程處理銷售過(guò)程開(kāi)機(jī)開(kāi)始一次新的銷售輸入商品項(xiàng)結(jié)束這次銷售付款2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程Object Design: enterltem當(dāng)收銀員輸入欲購(gòu)商品的itemID和數(shù)量時(shí), enterltem系統(tǒng)操作發(fā)生.2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程enterItem選擇控制器類 基于控制器模式,我們?nèi)匀贿x擇Register作為處理系統(tǒng)操作消息enterItem的控制器.2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程enterItem創(chuàng)建一個(gè)新的Sa

8、lesLineItem enterItem契約的后置條件表明需要?jiǎng)?chuàng)建、初始化以及建立與SalesLineItem的關(guān)聯(lián).根據(jù)領(lǐng)域模型和創(chuàng)建者模式,Sale的軟件對(duì)象是創(chuàng)建SalesLineItem對(duì)象的合適候選者.2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程enterItem尋找ProductSpecification SalesLineItem需要基于輸入的itemId與ProductSpecification建立聯(lián)系. 在itemId匹配的基礎(chǔ)上,誰(shuí)應(yīng)該知道ProductSpecification? 根據(jù)信息專家模式,以及領(lǐng)域模型

9、得知:ProductCatalog邏輯上包含了所有的ProductSpecifications. 所以, ProductCatalog是實(shí)現(xiàn)查找ProductSpecification職責(zé)的候選者.2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程enterItemVisibility to a ProductCatalog (1)Who should send the getSpecification message to the ProductCatalog to ask for a ProductSpecification? (2)It is reasonable to assume

10、that a Register and ProductCatalog instance were created during the initial start-up phase (or use case), and there is a permanent connection from Register to ProductCatalog. 2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程enterItem可見(jiàn)性(Visibility)是一個(gè)對(duì)象“看見(jiàn)”或擁有另一個(gè)對(duì)象引用的能力.2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程

11、Object Design: endSale當(dāng)收銀員按下結(jié)束銷售的按鈕時(shí)endSale系統(tǒng)操作發(fā)生.2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程endSale誰(shuí)應(yīng)該負(fù)責(zé)設(shè)置Sale的 plete屬性為true呢?根據(jù)信息專家模式,它應(yīng)是Sale本身,因?yàn)樗鼡碛泻途S護(hù) plete屬性2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程Object Design: makePayment當(dāng)收銀員輸入支付的現(xiàn)金總額時(shí),發(fā)生makePayment系統(tǒng)操作.2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程makePayment創(chuàng)建Payment (1)Who records, aggrega

12、tes, most closely uses or contains a Payment?Register logically records a PaymentSale will closely use a Payment2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程makePayment (2) Another way to find a creator is to use Expert. Who is the Information Expert for initializing the data the amount tendered.Register is the contro

13、ller which receives the system operation message makePayment, so again Register is a candidate.2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程makePayment (3) What about Low Coupling and High Cohesion?If the Sale is chosen to create payment, the Register will be lighter and probably more cohesiveSince in each case Sale w

14、ill be associated with Payment, why couple it with Register?2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程makePayment(4)What about the balance? 1. Who should be responsible for knowing the balance(余額)?Sale 2. What information is needed to calculate the balance?Total of the Sale, andAmount of Payment.2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方

15、法與技術(shù)”課程2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程Object Design: startUpMost, if not all, systems have a Start Up use case, and some initial system operation. Do the initialization design last.A common design idiom is to create an initial domain object.Near the root of the containment or ag

16、gregation hierarchy. E.g. Store.2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程startUp The initial domain object, once created, is responsible for the creation of its direct child domain objects. For example, if a Store is chosen as the initial domain object, it may be responsible for the creation of a Register object.2

17、022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程startUp The place where this initial domain object is created is dependent on the object technology chosen. For example, in a Java application, the main method may create it.2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程public class Main public static void main( String args ) /Store is the init

18、ial domain object. /The Store creates some other domain objects. Store store = new Store(); Register register = store.createRegister(); ProcessSaleJFrame frame = new ProcessSaleJFrame( register ); . startUp 2022/7/10東南大學(xué)“軟件開(kāi)發(fā)方法與技術(shù)”課程Store create()The tasks of creation and initialization derive from the needs of the prior design work. The following have been identified: A Store, Register, ProductCatalog and ProductSpecifica

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(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)論