chObjectOrientedDesignUseCaseRealizations实用学习教程.pptx
《chObjectOrientedDesignUseCaseRealizations实用学习教程.pptx》由会员分享,可在线阅读,更多相关《chObjectOrientedDesignUseCaseRealizations实用学习教程.pptx(60页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、1.OverviewThe use case realization is used to extend the process of detailed design.In use case realization,each use case is taken individually to determine all the classes that collaborate on it.As part of that process,any other utility or support classes are identified.Care is taken during this pr
2、ocess to definethe classes so the integrity of the multilayer architectural design is maintained.As the details of the classes are designed use case by use case the design classdiagram is also updated as necessary.10:55第1页/共60页2.Detailed Design of Multilayer SystemsCRC cards focus on collaborating d
3、omain objects to execute various use cases.In multilayer architecture,there are three objects representing the three layers of a system.Each object has certain responsibilities.The input window object has the primary responsibility of formatting and presenting student information on the screen.The s
4、tudent object represents the middle layer,or business logic layer,for the use case.The database access object represents the third layer in the multilayer design.10:55第2页/共60页Patterns of collaborating objectsPatterns,also called templates,are used repeatedly in everyday life.Patterns are created to
5、solve problems.Over time and with many attempts,people who work on a particular problem develop a set solution to the problem.The solution is general enough that it can be applied over and over again.As time passes,the solution is documented and published,and eventually it becomes accepted as the st
6、andard10:55第3页/共60页2.Detailed Design of Multilayer SystemsDesign patterns became a widely accepted object-oriented design technique in 1996.Elements of Reusable Object-Oriented Software,1996by Erich Gamma,Richard Helm,Ralph Johnson,and John Vlissides.These four authors are now referred to as the Gan
7、g of Four(GoF).10:55第4页/共60页Pattern:Controller10:55第5页/共60页Pattern specificationPattern specification has five main elements:1.Pattern name2.Problem that requires a solution3.Solution to or explanation of the pattern4.Example of the pattern5.Benefits and consequences of the pattern10:55第6页/共60页Patte
8、rn:ControllerProblem:Domain classes have the responsibility of processing use cases.1.However,since there can be many domain classes,which one(s)should be responsible for receiving the input messages?2.User interface classes become very complex if they have visibility to all of the domain classes.3.
9、How can the coupling between the user-interface classes and the domain classes be reduced?10:55第7页/共60页Pattern:ControllerSolution:Assign the responsibility for receiving input messages to a class that receives all input messages and acts as a switchboard to forward them to the correct domain class.T
10、here are several ways to implement this solution:1.Have a single class that represents the entire system,or2.Have a class for each use case or related group of use cases to act as a use case handler.10:55第8页/共60页Pattern:ControllerExample:The RMO Customer account subsystem accepts inputs from a:Custo
11、merForm window.These input messages are passed to the:CustomerHandler,which acts as the switchboard to forward the message to the correct problem domain class.10:55第9页/共60页Pattern:ControllerBenefits and Consequences:Coupling between the view layer and the domain layer is reduced.The controller provi
12、des a layer of indirection.The controller is closely coupled to many domain classes.If care is not taken,controller classes can become incoherent,with too many unrelated functions.If care is not taken,business logic will be inserted into the controller class.10:55第10页/共60页3.Use Case Realization with
13、 Sequence DiagramsDeveloping interaction diagrams is at the heart of object-oriented detailed design.The realization of a use case is to determine what objects collaborate and the messages they send to each other to carry out the use case.Two types of interaction diagrams:1.sequence diagrams municat
14、ion diagrams10:55Why?to design object collaboration第11页/共60页10:55ExampleUse Case:Create customer account第12页/共60页System sequence diagram for the Create customer account use caseThe system itself is treated as a single object named:System.第13页/共60页10:55The most important information on an System sequ
15、ence diagram(SSD)is the sequence of messages between the actor and the system.How to reduce(separate)responsibilities with objects.第14页/共60页10:55第15页/共60页Activation Lifelinea representation of the period during which a method of an object is alive and executing.10:55第16页/共60页10:55Its now to look at
16、the problem domain classes again and determine which classes are required for this use case.The Address class and the Account class are attached to Customer class.第17页/共60页10:55The Customer class has visibility to the other two classes:Account and Address.第18页/共60页10:55第19页/共60页10:55Its time is to d
17、etermine the internal messages that must be sent between the objects第20页/共60页How to design interactionsWhen identifying and creating messages,we must first determine the origin and destination objects for the message.The origin object is the one that needs information or help in carrying out a respo
18、nsibility so it will initiate a message.The destination object is the one that has the information to help in the solution and will receive the message and process it.After determining the origin and destination objects,we must name the message.Notice also that the input parameters provide the infor
19、mation that the destination object needs in order to provide the service.10:55第21页/共60页10:55ExampleUse Case:Fill Shopping Car第22页/共60页10:55Remember from Figure 3-16:The“Fill Shopping Car”use case“included”three other use cases.第23页/共60页10:55第24页/共60页10:55第25页/共60页.In UML,when a create message is sen
20、t to an object,it is often drawn directly to the objects box and not to the lifeline第26页/共60页Review:The relevant design principle is that objects that“own”other objects areresponsible for creating those objects;for example,a customer creates an online cart and then the online cart creates items in t
21、he cart.Another important consideration is navigation visibility.To send a message to the correct destination object,the source object must have visibility to the destination object.Remember that the purpose of doing design is to prepare for programming.10:55第27页/共60页Guidelines for First-Cut Sequenc
22、e Diagram DevelopmentDesigning a use case or scenario by using sequence diagrams involves performing these tasks:Take each input message and determine all the internal messages that result from that input.For each message,Determine its objective.Determine what information is needed,What class needs
23、it(the destination),and What class provides it(the source).Determine whether any objects are created as a result of the input.10:55第28页/共60页Guidelines for First-Cut Sequence Diagram DevelopmentAs you work with each input message,identify the complete set of classes that will be affected by the messa
24、geAny classes that are listed in either the preconditions or post conditions should be included in the design.Classes that are created during the use case,Classes that are the creators of objects for the use case,Classes that are updated during the use case Classes that provide information used in t
25、he use case.10:55第29页/共60页Guidelines for First-Cut Sequence Diagram DevelopmentFlesh out the components for each message;iteration,true/false conditions,return values,passed parameters.The passed parameters should be based on the attributes found in the domain class diagram.10:55第30页/共60页Assumptions
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- chObjectOrientedDesignUseCaseRealizations 实用 学习 教程
链接地址:https://www.taowenge.com/p-87123228.html
限制150内