freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

第7講模式與對象設(shè)計-資料下載頁

2025-10-08 13:05本頁面

【導(dǎo)讀】我們已經(jīng)創(chuàng)建了領(lǐng)域模型。確定有什么樣的方法,屬于誰,對象之間如何交。GRASP模式是幫助我們理解詳細的原則和所需。這些模式與如何將責任分配給類相關(guān)。自己做某些事情,例如創(chuàng)建一個對象或者進行一個計算??刂苹蛘邊f(xié)調(diào)其它對象的活動。知道私有的封裝的數(shù)據(jù)。“一個sale對象需要負責knowingitstotal”。Sale類可以定義一個或多個方法來計算總價。被命名為getTotal的方法。或者發(fā)送getSubTotal消息給每一個SalesLineItem對。責任可以通過編程實現(xiàn)。在我們?nèi)祟惿鐣?,許多方面的成功經(jīng)驗都可以。事實上,教育的重要目標就是把學習的模式從一代傳。學習開發(fā)高質(zhì)量的軟件與學習下棋非常類似。雖然失敗的后果通常沒有那么戲劇性。首先學習規(guī)則和物理需求。例如,棋子的名字,合法的移動,棋盤的構(gòu)成,等等。但是,要成為高手,還必須從其它人的棋譜中學。例如,結(jié)構(gòu)化編碼,模塊化編碼,面向?qū)ο缶幋a,遺。模式對專家的知識和設(shè)計中的優(yōu)缺點進行了顯示。擁有需要的信息的對象類確定總額

  

【正文】 Operation: makePayment(amount: Money) Cross References: Use Cases: Process Sale Preconditions: There is an underway sale. Postconditions: A Payment instance p was created (instance creation) became amount( attribute modification) p was associated with current Sale (association formed) The current Sale was associated with the Store (association formed)。 (to add it to the historical log of pleted sale) 上海交通大學計算機科學與工程系 2020/11/23 108 創(chuàng)建 Payment ?創(chuàng)建了 Payment 的實例 p (創(chuàng)建實例 ) ?這是一個創(chuàng)建職責 . ?兩個候選者 : ? Register ?In real domain a register records account information ?The Register is the controller which receives the system operation makePayment message ? Sale ?sale 對象頻繁使用 Payment 上海交通大學計算機科學與工程系 2020/11/23 109 當存在多個可選設(shè)計時,應(yīng)更深入地觀察可選設(shè)計所存在的內(nèi)聚和耦合,以及未來可能存在的進化壓力。選擇具有良好內(nèi)聚,耦合和在未來變化時能保持穩(wěn)定的設(shè)計 1: makePayment(cashTendered) : create(cashTendered) :Register :Sale :Payment makePayment(cashTendered) by Controller by Creator and Low Coupling 上海交通大學計算機科學與工程系 2020/11/23 110 記錄 Sale的日志 Store ... addSale(s : Sale) ... SalesLedger ... addSale(s : Sale) ... Store is responsible for knowing and adding pleted Sales. Acceptable in early development cycles if the Store has few responsibilities. SalesLedger is responsible for knowing and adding pleted Sales. Suitable when the design grows and the Store bees uncohesive. Sale ... ... Sale ... ... Logspleted 5 Logspleted 5 * * 1 1 上海交通大學計算機科學與工程系 2020/11/23 111 1: makePayment(cashTendered) : create(cashTendered) :Register s :Sale :Payment makePayment(cashTendered) :Store 2: addSale(s) pletedSales: Sale pletedSales: Sale : add(s) by Expert note that the Sale instance is named 39。s39。 so that it can be referenced as a parameter in messages 2 and 上海交通大學計算機科學與工程系 2020/11/23 112 計算余額 ?誰負責計算余額 ? ? Payment ? Sale ?兩個選擇 ? Payment: 它需要具有 Sale的可見性,以便向 Sale 請求銷售總額。它將增加整體設(shè)計的耦合度 . ? Sale: 它需要具有 Payment的可見性,由于它是創(chuàng)建者,因此并不增加總的耦合 上海交通大學計算機科學與工程系 2020/11/23 113 :Sale pmt: Payment 1: amt := getAmount() bal := getBalance() 2: t := getTotal() { bal = } Note the use of self in the constraint. The formal OCL uses the special variable self for this (in Java and C++). self in this constraint implies the instance of the Sale. Although official OCL is not being used, this style is borrowing from it. A constraint can be in any formal or informal language. 上海交通大學計算機科學與工程系 2020/11/23 114 對象設(shè)計 : startUp ?系統(tǒng)需要 Start Up, 它包含了某些初始化系統(tǒng)操作 . ?盡管這些 startUp 系統(tǒng)操作是最早要執(zhí)行的操作,但是在實際設(shè)計中要將該操作交互圖的開發(fā)推遲到其他所有系統(tǒng)操作的設(shè)計工作之后,這一實踐保證能夠發(fā)現(xiàn)所有相關(guān)初始化活動所需要的信息 最后完成初始化的設(shè)計 上海交通大學計算機科學與工程系 2020/11/23 115 如何完成應(yīng)用的啟動 ?應(yīng)用如何啟動和初始化與編程語言和操作系統(tǒng)有關(guān) ?常見的設(shè)計約定是創(chuàng)建一個初始領(lǐng)域?qū)ο? initial domain object. Public class Main { Public static void main (String [] args) //store is the initial domain object //The store creates some other domain objects Store store=new Store()。 Register register = ()。 ProcessSaleJFrame frame=new ProcessSaleJFrame(register)。 } } How to create the initial domain object is dependent on the object technology chosen. 上海交通大學計算機科學與工程系 2020/11/23 116 對 startUp系統(tǒng)操作的解釋 ?在交互圖中,發(fā)送一個 create() 消息以創(chuàng)建初始化領(lǐng)域?qū)ο? ?如果初始化對象負責過程控制,在第二個交互圖中,發(fā)送一個 run 消息給初始化對象 . 上海交通大學計算機科學與工程系 2020/11/23 117 POS應(yīng)用 ? startUp 系統(tǒng)操作發(fā)生于當經(jīng)理按下 POS系統(tǒng)的按鈕后軟件開始裝載 . ?假定初始化領(lǐng)域?qū)ο蟛回撠熆刂七^程,控制權(quán)將依舊在 UI 層 . ?對 startUP的 交互圖可能只是被解釋為一個 create() 消息 . 上海交通大學計算機科學與工程系 2020/11/23 118 選擇初始化領(lǐng)域?qū)ο? ?初始化領(lǐng)域?qū)ο蟮念愂鞘裁?? ? 選擇位于或接近于領(lǐng)域?qū)ο蟀蚓酆蠈哟沃械母愖鳛槌跏碱I(lǐng)域?qū)ο?。該類可能是外觀控制器,例如Register, 也可能是容納所有或大部分其它對象的某些對象,例如 Store. 上海交通大學計算機科學與工程系 2020/11/23 119 Persistent Objects: ProductSpecifiation ? ProductSpecification 實例需要放在永久存儲媒介中,例如關(guān)系數(shù)據(jù)庫或者對象數(shù)據(jù)庫 ?當需要時,單個實例可以按照需要取出來 上海交通大學計算機科學與工程系 2020/11/23 120 Storecreate() Design ?依據(jù)前面的設(shè)計工作 : ? Store, Register, ProductCatalog and ProductSpecifications 需要被創(chuàng)建 ? ProductCatalog 需要與 ProductSpecifications關(guān)聯(lián) ? Store 需要與 ProductCatalog關(guān)聯(lián) ? Store 需要與 Register關(guān)聯(lián) ? Register 需要與 ProductCatalog關(guān)聯(lián) 上海交通大學計算機科學與工程系 2020/11/23 121 :Store :Register pc: ProductCatalog create() 2: create(pc) 1: create() : loadProdSpecs() :Product Specification : create() *: add(ps) *: create(id, price, description) ps: ProductSpecification the * in sequence number indicates the message occurs in a repeating section pass a reference to the ProductCatalog to the Register, so that it has permanent visibility to it by Creator create an empty multiobject (., a Map), not a ProductSpecification 上海交通大學計算機科學與工程系 2020/11/23 122 如何將 UI層連接到領(lǐng)域?qū)? ?常見設(shè)計 : ? 從應(yīng)用的起始方法(例如, Java的 main方法 ) 中調(diào)用的初始化對象,同時創(chuàng)建 UI對象和領(lǐng)域?qū)ο?,并且將領(lǐng)域?qū)ο髠鬟f給 UI ? UI對象從眾所周知的源提取領(lǐng)域?qū)ο?,如一個負責創(chuàng)建領(lǐng)域?qū)ο蟮墓S對象 public class Main { public static void main (String[] args) { Store store =new Store()。 Register register=()。 ProcessSaleJFrame frame=new ProcessSaleJFrame( register)。 … } } 上海交通大學計算機科學與工程系 2020/11/23 123 :Register Cashier :ProcessSale JFrame actionPerformed( actionEvent ) 1: enterItem(id, qty) system event UI Layer Domain Layer presses button 上海交通大學計算機科學與工程系 2020/11/23 124 更多 .. ?需要知道總額 ?兩個選擇 ? 方案 1: 添加 getTotal 方法給 Register ? 方案 2: UI直接發(fā)送消息給 Sale 對象 ? 方案 1: 降低了 UI和領(lǐng)域?qū)拥鸟詈?。 擴展了 Register 對象,使得它的內(nèi)聚性降低 ? 方案 2: 增加了 UI層與領(lǐng)域?qū)拥鸟詈?,但是這種情形下不是問題 上海交通大學計算機科學與工程系 2020/11/23 125 :Register Cashier :ProcessSale JFrame actionPerformed( actionEvent ) 1: enterItem(id, qty) 2 [no sale] : s := getSale() : Sale UI Layer Domain Layer s : Sale 3: t := getTotal() presses button note the UML notation for a conditional message 上海交通大學計算機科學與工程系 2020/11/23 126 Interface and Domain Layer Responsibilities The UI layer should not have any domain logic responsibilities. It should o
點擊復(fù)制文檔內(nèi)容
教學課件相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1