软件需求分析英文课件:Chap 6-Design Model_第1页
软件需求分析英文课件:Chap 6-Design Model_第2页
软件需求分析英文课件:Chap 6-Design Model_第3页
软件需求分析英文课件:Chap 6-Design Model_第4页
软件需求分析英文课件:Chap 6-Design Model_第5页
已阅读5页,还剩63页未读, 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Elaboration Iteration 1-Design ModelpCh15. UML Interaction DiagramspCh16. UML Class Diagrams 1Chapter 15. UML Interaction Diagramso Objectiveso Provide a reference for frequently used UML interaction diagram notation(sequence and communication diagrams).2Sequence and Communication Diagrams oThe UML

2、includes interaction diagrams to illustrate how objects interact via messages. They are used for dynamic object modeling.3: AmyB : BdoTwodoOnedoThree: AmyB : B1: doTwo2: doThreedoOneStrengths and Weaknesses of Sequence vs. Communication Diagrams4Example Sequence Diagram: makePayment5: Register: Sale

3、makePayment(cashTendered)makePayment(cashTendered) : Paymentcreate(cashTendered)Example Communication Diagram: makePayment61: makePayment(cashTendered)1.1: create(cashTendered):Register:Sale:PaymentmakePayment(cashTendered) direction of messageNovice UML Modelers Dont Pay Enough Attention to Interac

4、tion Diagrams !oMost UML novices are aware of class diagrams and usually think they are the only important diagram in OO design. Not true! oAlthough the static-view class diagram are indeed useful, the dynamic-view interaction diagrams are incredibly valuable. oSpend time doing dynamic object modeli

5、ng with interaction diagrams, not just static object modeling with class diagrams.7Common UML Interaction Diagram NotationoIllustrating Participants with Lifeline Boxes8oBasic Message Expression SyntaxoSingleton Objects9Basic Sequence Diagram NotationoMessages and focus of control with execution spe

6、cification bar10: Register: SaledoAdoBdoXdoCdoDtypical sychronous message shown with a filled-arrow linea found message whose sender will not be specifiedexecution specification bar indicates focus of controloIllustrating Reply or Returns11: Register: Saled1 = getDategetDatedoXaDateoMessages to self

7、 or this“oCreation of Instances12: RegisterdoXclear: Register: SalemakePayment(cashTendered): Paymentcreate(cashTendered)authorizenote that newly created objects are placed at their creation heightoObject Lifelines and Object Destruction13oDiagram Frames in UML Sequence Diagrams14enterItem(itemID, q

8、uantity): BendSalea UML loop frame, with a boolean guard expressiondescription, totalmakeNewSale more items loop: Aocommon frame operators15oConditional Messages16calculate: Baryyxx color = red opt: Foo color = red calculate: Baryyxx: FooUML 1.x notational simple styleoMutually Exclusive Conditional

9、 Messages17: B: AcalculatedoX: Ccalculate x 10 alt else oIteration Over a Collection18Iteration over a collection using relatively explicit notationoIteration Over a Collection19Iteration over a collection leaving things more implicitoIteration Over a Collection20oNesting of Frames21calculate: Barxx

10、 color = red opt: Fooloop(n)oHow to Relate Interaction Diagrams?22interaction occurrencenote it covers a set of lifelinesnote that the sd frame it relates to has the same lifelines: B and CdoA: A: B: CdoBsd AuthenticateUserrefAuthenticateUserauthenticate(id)doXdoM1: B: Cauthenticate(id)doM2refDoFoos

11、d DoFoodoX: B: CdoYdoZoMessages to Classes to Invoke Static (or Class) Methods23oPolymorphic Messages and Cases24oAsynchronous and Synchronous Calls25oAsynchronous and Synchronous Calls26Basic Communication Diagram NotationoLinksoMessages271: makePayment(cashTendered)2: foo2.1: bar: Register:Salelin

12、k line1: msg22: msg33: msg43.1: msg5: Register:Saleall messages flow on the same linkmsg1oMessages to self or this28: Registermsg11: clearoCreation of Instances29oMessage Number Sequencing30: Amsg1: B1: msg2: C1.1: msg3not numberedlegal numbering31: Amsg1: B1: msg2: C1.1: msg32.1: msg52: msg4: D2.2:

13、 msg6firstsecondfourthsixthfifththirdoMessage Number SequencingoConditional Messages321 color = red : calculate: Foo: Barmessage1conditional message, with testoMutually Exclusive Conditional Paths331a test1 : msg2: A: B: C1a.1: msg3msg1: D1b not test1 : msg41b.1: msg5: E2: msg6unconditional after ei

14、ther msg2 or msg41a and 1b are mutually exclusive conditional pathsoIteration or Looping341 * i = 1.n : num = nextInt: SimulatorrunSimulation: Randomiteration is indicated with a * and an optional iteration clause following the sequence numberoIteration Over a Collection35oMessages to a Classes to I

15、nvoke Static (Class) Methods36oPolymorphic Messages and Cases37oAsynchronous and Synchronous Calls383: runFinalization:ClockStarterSystem : ClassstartClock:Clock1: create2: runasynchronous messageactive objectChapter 16. UML Class Diagramso Objectiveso Provide a reference for frequently used UML cla

16、ss diagram notation.39Applying UML: Common Class Diagram Notation40java.awt:Fontorjava.awt.Fontplain : Int = 0 readOnly bold : Int = 1 readOnly name : Stringstyle : Int = 0.getFont(name : String) : FontgetName() : SerfaceRunnablerun()- ellipsis “” means there may be elements, but not shown-

17、 a blank compartment officially means “unknown” but as a convention will be used to mean “no members”SubclassFoo.run().SuperclassFooorSuperClassFoo abstract - classOrStaticAttribute : Int+ publicAttribute : String- privateAttributeassumedPrivateAttributeisInitializedAttribute : Bool = trueaCollectio

18、n : VeggieBurger * attributeMayLegallyBeNull : String 0.1 finalConstantAttribute : Int = 5 readOnly /derivedAttribute + classOrStaticMethod()+ publicMethod()assumedPublicMethod()- privateMethod()# protectedMethod() packageVisibleMethod()constructor SuperclassFoo( Long )methodWithParms(parm1 : String

19、, parm2 : Float)methodReturnsSomething() : VeggieBurgermethodThrowsException() exception IOExceptionabstractMethod()abstractMethod2() abstract / alternatefinalMethod() leaf / no override in subclasssynchronizedMethod() guarded 3 common compartments1. classifier name2. attributes3. operationsinterfac

20、e implementation andsubclassingFruit.PurchaseOrder.1association with multiplicitiesdependency officially in UML, the top format is used to distinguish the package name from the class nameunofficially, the second alternative is commonorderan interface shown with a keywordDefinition: Design Class Diag

21、ram41Register.endSale()enterItem(.)makePayment(.)SaletimeisComplete : Boolean/totalmakeLineItem(.)Register.SaletimeisComplete : Boolean/totalCaptures111Domain Modelconceptual perspectiveDesign ModelDCD; software perspectivecurrentSale1. Definition: ClassifieroA UML classifier is “a model element tha

22、t describes behavioral and structure feature”. oClassifier can also be specialized. They are a generalization of many of the elements of the UMLnClasses nInterfaces nUse cases nActors oIn class diagram, the two most common classifier are regular classes and interfaces422. Ways to Show UML Attributes

23、: Attribute Text and Association Lines43Register.Sale.1RegistercurrentSale : Sale.Sale.using the attribute text notation to indicate Register has a reference to one Sale instanceusing the association notation to indicate Register has a reference to one Sale instanceOBSERVE: this style visually empha

24、sizes the connection between these classescurrentSaleRegistercurrentSale : Sale.Sale.1thorough and unambiguous, but some people dislike the possible redundancycurrentSaleoIdioms in association notation usage in different perspectives44the association name, common when drawing a domain model, is ofte

25、n excluded (though still legal) when using class diagrams for a software perspective in a DCDRegisterid: Int.Saletime: DateTime.1currentSaleRegisterid : IntSaletime : DateTimeCaptures-current-sale11UP Domain Modelconceptual perspectiveUP Design ModelDCDsoftware perspectiveoGuideline: When to Use Att

26、ribute Text versus Association Lines for Attributes?45Registerid: Int.Saletime: DateTime.1applying the guideline to show attributes as attribute text versus as association linesStoreaddress: Addressphone: PhoneNumber.1Register has THREE attributes:1. id2. currentSale3. locationcurrentSalelocationoHo

27、w to Show Collection Attributes with Attribute Text and Association Lines?46notice that an association end can optionally also have a property string such as ordered, ListSaletime: DateTime.SalesLineItem.1.*lineItemsordered, ListSaletime: DateTimelineItems : SalesLineItem 1.* orlineItems : SalesLine

28、Item 1.* ordered.SalesLineItem.Two ways to show a collection attribute3. Note Symbols: Notes, Comments, Constraints, and Method BodiesoNote symbols can be used on any UML diagram, but are especially common on class diagrams oA UML note symbol is displayed as a dog-eared rectangle with a dashed line

29、to be annotated element; oA note symbol may represent several things na UML note or comment, having no semantic impact na UML constraint, must be encased in braces na method body474. Operations and MethodsoOne of the compartments of the UML class box shows the signature of operationsoOperations are

30、usually assumed public if no visibility is shown oAn operation is not a method. It is a declaration. Method are implementations48oHow to Show Methods in Class Diagrams?49o Operation Issues in DCDsn The create operation oThe create message in an interaction diagram is normally interpreted as the invo

31、cation of the new operator and a constructor call oIn a DCD this create message will usually be mapped to a constructor definition, using the rules of the language n Operations to Access Attributes oOften excluded (or filtered) from the class diagram505. KeywordsoA UML keyword is a textual adornment

32、 to categorize a model element oMost keywords are shown in guillemet ( ) but some are shown in curly braces abstract osample predefined UML keywords include:51Stereotypes, Profiles, and Tags526. Generalization, Abstract Classes, Abstract OperationsoGeneralization is a taxonomic relationship between

33、a more general classifier and more specific classifier nEach instance of the specific classifier is also an indirect instance of the general classifier. nThe specific classifier indirectly has features of the more general classifier nIs shown in UML with a solid line and fat triangular arrows from t

34、he subclasses to supper classes53DependencyoIn UML, a dependency relationship indicates that a client element has knowledge of another supplier element and that a change in the supplier could affect the clientoThere are many kinds of dependency, here are some common types in terms of objects and cla

35、ss diagramsnHaving an attribute of the supplier type nSending a message to a supplier,the visibility to the supplier nReceiving a parameter of the supplier type nThe supplier is a superclass or interface oIn class diagrams use the dependency line to depict the following dependency between objects ng

36、lobal, parameter variablenlocal variablenstatic-method call5455SalesLineItem.ProductDescription.1.*lineItemsSale.updatePriceFor( ProductDescription ).the Sale has parameter visibility to a ProductDescription, and thus some kind of dependencyoExample56oAnother ExampleSystem.runFinalization().Foo.doX(

37、).the doX method invokes the runFinalization static method, and thus has a dependency on the System classoOptional dependency labels577. Interfaces58interfaceTimergetTime()Clock1.getTime().lollipop notation indicates Clock3 implements and provides the Timer interface to clientsTimer is a provided in

38、terfaceTimerClock3.getTime().Window2Window3dependency line notationWindow2 has a dependency on the Timer interface when it collaborates with a Clock2 objectsocket line notationWindow3 has a dependency on the Timer interface when it collaborates with a Clock3 objectWindow1Timersocket line notationWin

39、dow1 uses the Timer interface it has a required interfaceClock2.getTime().Clock1 implements and provides the Timer interfaceTimer8. Composition Over AggregationoAggregation is a kind of association that loosely suggests whole-part relationship oComposition is a strong kind of whole-part aggregation

40、and is useful to show in some models oA composition relationship implies that nAn instance of the part belongs to only one composite instance at a time nThe part will be always belong to the composite nThe composite is responsible for the creation and deletion of its parts either by itself creating/

41、deleting the parts, or by collaborating with other objects59oComposition in the UML60Finger0.7Handcomposition1Square40Board1SalesLineItem1.*Sale1composition means -a part instance (Square) can only be part of one composite (Board) at a time -the composite has sole responsibility for management of its parts, especially creation and deletion9. Constraints6110. Qualified association

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论