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

Post on 30-Dec-2015

221 views 2 download

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

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, (2nd Edition), McGraw Hill, 2002.

© Bennett, McRobb and Farmer 2002 2

In This Lecture You Will In This Lecture You Will Learn:Learn:

How to develop object collaboration from use cases

How to model object collaboration using an interaction sequence diagram

How to model object collaboration using an interaction collaboration diagram

© Bennett, McRobb and Farmer 2002 3

Object MessagingObject Messaging

Objects communicate by sending messages

© Bennett, McRobb and Farmer 2002 4

Sequence DiagramsSequence Diagrams

Show an interaction between objects arranged in a time sequence

Can be drawn at different levels of detail and to meet different purposes at several stages in the development life cycle

Interactions are in the form of messages

© Bennett, McRobb and Farmer 2002 5

Sequence DiagramsSequence Diagrams

Dotted vertical line represents object’s lifeline.

Vertical dimension shows time Thin bars represent focus of control,

periods of time when object is behaving (fulfilling responsibilities).

Messages are shown by a solid horizontal arrow

The execution of an operation is shown by an activation

© Bennett, McRobb and Farmer 2002 6

Sequence diagramSequence diagram

:Client :Campaign :Advert getName()

listCampaigns()

listAdverts()

*getCampaign Details()

Advert()

*getAdvertDetails()

newAd:Advert

addNewAdvert()

Object lifeline

Activation

Object creation

Campaign Manager

© Bennett, McRobb and Farmer 2002 7

© Bennett, McRobb and Farmer 2002 8

Boundary & Control ClassesBoundary & 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.

© Bennett, McRobb and Farmer 2002 9

Boundary & Control ClassesBoundary & 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

© Bennett, McRobb and Farmer 2002 10

© Bennett, McRobb and Farmer 2002 11

Object DestructionObject Destruction

listAdverts()

deleteAdvert()

Object destruction

:Campaign :Advert

destroy()

*getAdvertDetails()

X

© Bennett, McRobb and Farmer 2002 12

Reflexive MessagesReflexive Messages

:Client :Campaign :Advert getName()

listCampaigns()

checkCampaignBudget()

*getCampaign Details()

*getCost()

getOverheads()

Campaign Manager

© Bennett, McRobb and Farmer 2002 14

Focus of ControlFocus of Control

Indicates times during an activation when processing is taking place within that object

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

May be shown by shading those parts of the activation rectangle that correspond to active processing by an operation

© Bennett, McRobb and Farmer 2002 15

Focus of ControlFocus of Control

:Client :Campaign :Advert getName()

listCampaigns()

checkCampaignBudget()

*getCampaignDetails()

* getCost()

getOverheads()

Campaign Manager

© Bennett, McRobb and Farmer 2002 16

ReturnReturn

A return is a return of control to the object that originated the message that began the activation

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

© Bennett, McRobb and Farmer 2002 17

Handling ComplexityHandling Complexity

Complex diagrams can be split into two or more smaller diagrams suitably annotated

Alternatively a group of objects can be represented by a single lifeline, and interaction among these objects is shown on a different diagram

© Bennett, McRobb and Farmer 2002 18

Handling ComplexityHandling Complexity

:AddAdvertUI

:AddAdvert

showClientCampaigns()selectClient()

selectCampaign() showCampaignAdverts()

createNewAdvert()addNewAdvert()

listCampaigns()

addNewAdvert()

listAdverts()

These flows are continued next figure

startInterface()*getClient()

Campaign Manager

© Bennett, McRobb and Farmer 2002 19

Handling ComplexityHandling Complexity

listCampaigns()

addNewAdvert()

listAdverts()

*getCampaignDetails()

Advert()

*getAdvertDetails()

:Client :Campaign

:Advert

newAd:Advert

These flows are continued

from the previous figure

*getClient()

© Bennett, McRobb and Farmer 2002 20

Collaboration DiagramsCollaboration Diagrams

Hold the same information as sequence diagrams

Show links between objects that participate in the collaboration

No time dimension, sequence is captured with sequence numbers

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

ExamplesExamplesHow does the cellular phone work? To keep things simple, lets just look at

how a customer might make a phone call. The use case for this interaction looks like this:

Use case: Make Phone Call1. User presses the digit buttons to enter the phone number.2. For each digit, the display is updated to add the digit to thephone number.3. For each digit, the dialer generates the corresponding tone andemits it from the speaker.4. User presses “Send”5. The “in use” indicator is illuminated on the display6. The cellular radio establishes a connection to the network.7. The accumulated digits are sent to the network.8. The connection is made to the called party.

© Bennett, McRobb and Farmer 2002 21

Collaboration DiagramsCollaboration Diagrams

© Bennett, McRobb and Farmer 2002 22

© Bennett, McRobb and Farmer 2002 23

Collaboration DiagramsCollaboration 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

© Bennett, McRobb and Farmer 2002 24

Collaboration DiagramsCollaboration 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

© Bennett, McRobb and Farmer 2002 25

Navigating LinksNavigating Links

© Bennett, McRobb and Farmer 2002 26

SummarySummary

In this lecture you have learned about: How to develop object collaboration

from use cases How to model object collaboration using

an interaction sequence diagram How to model object collaboration using

an interaction collaboration diagram

© Bennett, McRobb and Farmer 2002 27

ReferencesReferences

UML Reference Manual (OMG, 2001)

(For full bibliographic details, see Bennett, McRobb and Farmer)