Presentation is loading. Please wait.

Presentation is loading. Please wait.

03/12/2001 © Bennett, McRobb and Farmer 2002 1 Object Interaction Based on Chapter 9 of Bennett, McRobb and Farmer: Object Oriented Systems Analysis and.

Similar presentations


Presentation on theme: "03/12/2001 © Bennett, McRobb and Farmer 2002 1 Object Interaction Based on Chapter 9 of Bennett, McRobb and Farmer: Object Oriented Systems Analysis and."— Presentation transcript:

1 03/12/2001 © Bennett, McRobb and Farmer 2002 1 Object Interaction Based on Chapter 9 of Bennett, McRobb and Farmer: Object Oriented Systems Analysis and Design Using UML, (2 nd Edition), McGraw Hill, 2002.

2 © Bennett, McRobb and Farmer 2002 2 In This Lecture You Will Learn: n How to develop object collaboration from use cases n How to model object collaboration using an interaction sequence diagram n How to model object collaboration using an interaction collaboration diagram n How to cross-check between interaction diagrams and a class diagram

3 © Bennett, McRobb and Farmer 2002 3 Object Messaging :Campaign anAdvert:Advert getCost( ) n Objects communicate by sending messages n Sending the message getCost() to an Advert object, might use the following syntax advertCost = anAdvert.getCost()

4 © Bennett, McRobb and Farmer 2002 4 Resilience of Design Real-world requirements Application that caters for these requirements Equivalent areas of change—a highly resilient system. A small change in requirements causes a much greater change in software—not a resilient system. Real-world requirements Application that caters for these requirements

5 © Bennett, McRobb and Farmer 2002 5 Interaction & Collaboration n 'The structure of Instances playing roles in a behavior and their relationships is called a Collaboration.‘ n 'An Interaction is defined in the context of a Collaboration. It specifies the communication patterns between the roles in the Collaboration. More precisely, it contains a set of partially ordered Messages, each specifying one communication, e.g. what Signal to be sent or what Operation to be invoked, as well as the roles played by the sender and the receiver, respectively.' UML (OMG, 2001)

6 © Bennett, McRobb and Farmer 2002 6 Sequence Diagrams n Show an interaction between objects arranged in a time sequence n Can be drawn at different levels of detail and to meet different purposes at several stages in the development life cycle n Typically used to represent the detailed object interaction that occurs for one use case or for one operation

7 © Bennett, McRobb and Farmer 2002 7 Sequence Diagrams n Vertical dimension shows time n Objects involved in interaction appear horizontally across the page and represented by lifelines n Messages are shown by a solid horizontal arrow n The execution of an operation is shown by an activation

8 © Bennett, McRobb and Farmer 2002 8 Sequence diagram :Client :Campaign :Advert getName() listCampaigns() listAdverts() *getCampaign Details() Advert() *getAdvert Details() newAd:Advert addNewAdvert() Object lifeline Activation Object creation Campaign Manager

9 © Bennett, McRobb and Farmer 2002 9 Boundary & Control Classes Most use cases imply at least one boundary object that manages the dialogue between the actor and the system – in the next sequence diagram it is :AddAdvertUI The control object is :AddAdvert and this manages the overall object communication.

10 © Bennett, McRobb and Farmer 2002 10 Boundary & Control Classes listCampaigns() *getCampaignDetails() Advert() *getAdvertDetails() addNewAdvert() :AddAdvertUI :AddAdvert :Client :Campaign :Advert showClientCampaigns() selectClient() selectCampaign() showCampaignAdverts() listAdverts() createNewAdvert() addNewAdvert() newAd:Advert startInterface() *getClient() Campaign Manager Use Case: Add a new advert to a campaign

11 © Bennett, McRobb and Farmer 2002 11 Object Destruction listAdverts() deleteAdvert() Object destruction :Campaign :Advert destroy() *getAdvertDetails() X

12 © Bennett, McRobb and Farmer 2002 12 Reflexive Messages :Client :Campaign :Advert getName() listCampaigns() checkCampaignBudget() *getCampaign Details() *getCost() getOverheads() Campaign Manager

13 © Bennett, McRobb and Farmer 2002 13 Focus of Control n Indicates times during an activation when processing is taking place within that object n Parts of an activation that are not within the focus of control represent periods when, for example, an operation is waiting for a return from another object n May be shown by shading those parts of the activation rectangle that correspond to active processing by an operation

14 © Bennett, McRobb and Farmer 2002 14 Focus of Control :Client :Campaign :Advert getName() listCampaigns() checkCampaignBudget() *getCampaignDetails() * getCost() getOverheads() Campaign Manager

15 © Bennett, McRobb and Farmer 2002 15 Return n A return is a return of control to the object that originated the message that began the activation n Returns are shown with a dashed arrow, but it is optional to show them at all since it can be assumed that control is returned to the originating object at the end of the activation

16 © Bennett, McRobb and Farmer 2002 16 Message Types n A synchronous message or procedural call, shown with a full arrowhead, causes the invoking operation to suspend execution until the focus of control has been returned to it n An asynchronous message, drawn with an open arrowhead, does not cause the invoking operation to halt execution while it awaits a return

17 © Bennett, McRobb and Farmer 2002 17 Further Notation :ClassA :ClassB a b {b.sendtime – a.sendtime < 3 sec} c < 5 sec. d {d.receivetime – d.sendtime < 1.5 sec} e {e.sendtime - d.receivetime < 6 sec} Synchronous (blocking) message Asynchronous message Callback Time constraints Construction marks to show time constrained interval {e’ – e < 6 sec} An active object Here e is used as shorthand for e.sendtime and e ’ represents e.receivetime

18 © Bennett, McRobb and Farmer 2002 18 Message Branching [totalCost  budget] Advert() addCostedAdvert() [ totalCost > budget] Request() newAd:Advert newRequest:Request :Campaign budget:=checkCampaignBudget() checkCampaignBudget() results in further interaction Campaign Manager

19 © Bennett, McRobb and Farmer 2002 19 Handling Complexity n Complex diagrams can be split into two or more smaller diagrams suitably annotated n Alternatively a group of objects can be represented by a single lifeline, and interaction among these objects is shown on a different diagram

20 © Bennett, McRobb and Farmer 2002 20 Handling Complexity :AddAdvertUI :AddAdvert showClientCampaigns() selectClient() selectCampaign() showCampaignAdverts() createNewAdvert() addNewAdvert() listCampaigns() addNewAdvert() listAdverts() These flows are continued next figure startInterface() *getClient() Campaign Manager

21 © Bennett, McRobb and Farmer 2002 21 Handling Complexity listCampaigns() addNewAdvert() listAdverts() *getCampaignDetails() Advert() *getAdvertDetails() :Client :Campaign :Advert newAd:Advert These flows are continued from the previous figure *getClient()

22 © Bennett, McRobb and Farmer 2002 22 Object Grouping Lifeline representing a set of objects getName() CampaignAdverts checkCampaignBudget() :Client listCampaigns() Campaign Manager

23 © Bennett, McRobb and Farmer 2002 23 Collaboration Diagrams n Hold the same information as sequence diagrams n Show links between objects that participate in the collaboration n No time dimension, sequence is captured with sequence numbers n Sequence numbers are written in a nested style (for example, 3.1 and 3.1.1) to indicate the nesting of control within the interaction that is being modelled

24 © Bennett, McRobb and Farmer 2002 24 Collaboration Diagrams 3.1.1: listCampaigns() 3.1.1.1: *getCampaignDetails() 5.1.1.1: Advert() 4.1.1.1: *getAdvertDetails() 5.1.1: addNewAdvert() :AddAdvertUI :AddAdvert :Client:Campaign:Advert 3.1: showClientCampaigns() 3: selectClient() 4: selectCampaign() 4.1: showCampaignAdverts() 4.1.1: listAdverts() 5: createNewAdvert() 5.1: addNewAdvert() newAd:Advert 2: startInterface() 1:*getClient() Campaign Manager One allocation of responsibilities for use case Add a new advert to a campaign

25 © Bennett, McRobb and Farmer 2002 25 Collaboration Diagrams 3.1.2: *getCampaignDetails() 5.1.1.1: Advert() 4.1.2: *getAdvertDetails() 5.1.1: addNewAdvert() :AddAdvertUI :AddAdvert :Client:Campaign :Advert 3.1: showClientCampaigns() 3: selectClient() 4: selectCampaign() 4.1: showCampaignAdverts() 4.1.1: listAdverts() 5: createNewAdvert() 5.1: addNewAdvert() newAd:Advert 2: startInterface() 3.1.1: listCampaigns() 1:*getClient() Campaign Manager Alternative allocation of responsibilities for use case Add a new advert to a campaign

26 © Bennett, McRobb and Farmer 2002 26 Message Labels Type of messageSyntax example Simple message. 4: addNewAdvert() Nested call with return value. The return value is placed in the variable name. 3.1.2: name:= getName() Conditional message. This message is only sent if the condition [balance > 0] is true. [balance > 0] 5: debit(amount) Synchronization with other threads. Message 4: playVideo() is invoked only once the two concurrent messages 3.1a and 3.1b are completed. 3.1a, 3. 1b / 4:playVideo()

27 © Bennett, McRobb and Farmer 2002 27 Navigating Links

28 © Bennett, McRobb and Farmer 2002 28 Model Consistency n The allocation of operations to objects must be consistent with the class diagram and the message signature must match that of the operation –Can be enforced through CASE tools n Every sending object must have the object reference for the destination object –Either an association exists between the classes or another object passes the reference to the sender –This issue is key in determining association design (See Chapter 14) –Message pathways should be carefully analysed

29 © Bennett, McRobb and Farmer 2002 29 Model Consistency n If both sequence and collaboration diagrams are prepared they should be consistent n Messages on interaction diagrams must be consistent with the statecharts for the participating objects n Implicit state changes in interaction diagrams must be consistent with those explicitly modelled in statecharts

30 © Bennett, McRobb and Farmer 2002 30 Summary In this lecture you have learned about: n How to develop object collaboration from use cases n How to model object collaboration using an interaction sequence diagram n How to model object collaboration using an interaction collaboration diagram n How to cross-check between interaction diagrams and a class diagram

31 © Bennett, McRobb and Farmer 2002 31 References n UML Reference Manual (OMG, 2001) (For full bibliographic details, see Bennett, McRobb and Farmer)


Download ppt "03/12/2001 © Bennett, McRobb and Farmer 2002 1 Object Interaction Based on Chapter 9 of Bennett, McRobb and Farmer: Object Oriented Systems Analysis and."

Similar presentations


Ads by Google