Chapter 18使用GRASP的对象设计示例
Chapter 18 使用GRASP的对象设计示例
大纲用例实现应用GRASP为类分配职责应用UML阐述和思考对象的设计
大纲 ⚫ 用例实现 ⚫ 应用GRASP为类分配职责 ⚫ 应用UML阐述和思考对象的设计
什么是用例实现用例如何在设计模型中实现systemasblackboxthenamecouldbe"NextGenPOS"but"System"keepsitsimplethe"."and underline implyan instance,and are explained in alaterchapteronsequencediagramnotationintheUMLexternal actortoProcess Sale Scenariosystem:System:CashiermakeNewSaleaUMLloop[moreitems]loopinteractionenterltem(itemlD,quantity)frame,withabooleanguarddescription,totalexpressionamessagewithendSaleparametersreturn value(s)associatedwiththeitisanabstractiontotal withtaxespreviousmessagerepresentingthesystemeventofanabstractionthatenteringthemakePayment(amount)ignorespresentationpayment data byandmediumsomemechanismthe return line ischangedue.receiptoptional if nothing isreturned
什么是用例实现 ⚫ 用例如何在设计模型中实现 enterItem(itemID, quantity) : Cashier :System endSale makePayment(amount) a UML loop interaction frame, with a boolean guard expression external actor to system Process Sale Scenario system as black box the name could be "NextGenPOS" but "System" keeps it simple the ":" and underline imply an instance, and are explained in a later chapter on sequence diagram notation in the UML a message with parameters it is an abstraction representing the system event of entering the payment data by some mechanism description, total return value(s) associated with the previous message an abstraction that ignores presentation and medium the return line is optional if nothing is returned total with taxes change due, receipt makeNewSale loop [ more items ]
系统事件makeNewSale,etc.,arethesystemoperationsfromtheSSDeachmajorinteractiondiagramstartswithasystemoperationgoingintoadomainlayercontrollerobject,suchasRegister1: ???makeNewSale:RegisterWindowobjectsor11:???→enterltemGUlwidgetobjects:Registeror1Webcontrolobjects11:???→endSale:Register-1makePayment1:???:Register11UILAYERDOMAINLAYER
系统事件 :Register enterItem :Register endSale :Register makePayment 1: ??? 1: ??? 1: ??? :Register makeNewSale 1: ??? makeNewSale, etc., are the system operations from the SSD each major interaction diagram starts with a system operation going into a domain layer controller object, such as Register UI LAYER DOMAIN LAYER Window objects or GUI widget objects or Web control objects . .
用例实现:Register1makeNewSalecreate:SaleWindowobjects/orGUIwidgetobjectsor一Webcontrol objects: Register:ProductCatalogenterltem(..)desc=getProductDesc(itemID)1111UILAYERDOMAINLAYER
用例实现 : Register : Sale makeNewSale create : Register enterItem(.) : ProductCatalog desc = getProductDesc( itemID ) . . . UI LAYER Window objects or GUI widget objects or Web control objects . . . DOMAIN LAYER