0% found this document useful (0 votes)
5 views31 pages

Object Interaction and Collaboration Diagrams

Uploaded by

unstable da
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views31 pages

Object Interaction and Collaboration Diagrams

Uploaded by

unstable da
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd

Object Interaction

Based on Chapter 9 of Bennett, McRobb


and Farmer:
Object Oriented Systems Analysis and
Design Using UML, (2nd Edition), McGraw
Hill, 2002.
03/12/2001 © Bennett, McRobb and Farmer 2002 1
In This Lecture You Will
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
 How to cross-check between interaction
diagrams and a class diagram

© Bennett, McRobb and Farmer 2002 2


Object Messaging
 Objects communicate by sending
messages
 Sending the message getCost() to
an Advert object, might use the
following syntax
advertCost = [Link]()
:Campaign anAdvert:Advert

getCost( )

© Bennett, McRobb and Farmer 2002 3


Resilience Equivalent areas of

of Design
change—a highly
resilient system.

Application that caters


Real-world for these requirements
requirements A small change in
requirements causes a
much greater change in
software—not a resilient
system.

Application that caters


Real-world for these requirements
requirements
© Bennett, McRobb and Farmer 2002 4
Interaction & Collaboration
 'The structure of Instances playing roles in a
behavior and their relationships is called a
Collaboration.‘
 '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)

© Bennett, McRobb and Farmer 2002 5


Sequence 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
 Typically used to represent the detailed
object interaction that occurs for one
use case or for one operation
© Bennett, McRobb and Farmer 2002 6
Sequence Diagrams
 Vertical dimension shows time
 Objects involved in interaction
appear horizontally across the
page and represented by lifelines
 Messages are shown by a solid
horizontal arrow
 The execution of an operation is
shown by an activation
© Bennett, McRobb and Farmer 2002 7
Sequence diagram
Campaign
Manager
:Client :Campaign :Advert
getName()
listCampaigns() *getCampaign
Details()

listAdverts() *getAdvert
Details()

addNewAdvert()
Advert()
newAd:Advert

Activation
Object lifeline
Object creation
© Bennett, McRobb and Farmer 2002 8
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.
© Bennett, McRobb and Farmer 2002 9
Boundary & Control Classes
Use Case: Add a new advert to a campaign
Campaign :AddAdvert :Client :Campaign :Advert
Manager
:AddAdvertUI *getClient()
startInterface()

selectClient()
showClientCampaigns()
listCampaigns() *getCampaignDetails()

selectCampaign() showCampaignAdverts()
listAdverts() *getAdvertDetails()

createNewAdvert()
addNewAdvert()
addNewAdvert()
Advert() newAd:Advert

© Bennett, McRobb and Farmer 2002 10


Object Destruction

:Campaign :Advert

listAdverts()
*getAdvertDetails()

deleteAdvert()
destroy()

Object destruction

© Bennett, McRobb and Farmer 2002 11


Reflexive Messages
Campaign
Manager
:Client :Campaign :Advert
getName()

listCampaigns() *getCampaign
Details()

checkCampaignBudget()
*getCost()

getOverheads()

© Bennett, McRobb and Farmer 2002 12


Focus 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 13
Focus of Control
Campaign
Manager
:Client :Campaign :Advert
getName()

listCampaigns()
*getCampaignDetails()

checkCampaignBudget()
* getCost()

getOverheads()

© Bennett, McRobb and Farmer 2002 14


Return
 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 15
Message Types
 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
 An asynchronous message, drawn with
an open arrowhead, does not cause the
invoking operation to halt execution
while it awaits a return
© Bennett, McRobb and Farmer 2002 16
Further Notation
:ClassA :ClassB
Synchronous
(blocking)
message

An active a
Asynchronous
object message

{[Link] – Construction
b
[Link] < 3 sec} marks to show
< 5 sec. time
constrained
c
interval
{[Link] –
d
[Link] < 1.5 sec} Callback

{[Link] -
[Link] Here e is used as
< 6 sec} shorthand for
[Link] and
e e’ represents
Time {e’ – e < 6 sec} [Link]
constraints

© Bennett, McRobb and Farmer 2002 17


Message Branching
:Campaign
Campaign
Manager checkCampaignBudget(
budget:=checkCampaignBudget() ) results in further
interaction

addCostedAdvert()
[totalCost  budget] Advert()
newAd:Advert

newRequest:Request
[totalCost > budget] Request()

© Bennett, McRobb and Farmer 2002 18


Handling 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 19
Handling Complexity
Campaign :AddAdvert
Manager
:AddAdvertUI *getClient() These flows are
startInterface() continued
next figure
selectClient()
showClientCampaigns()
listCampaigns()

selectCampaign() showCampaignAdverts()
listAdverts()

createNewAdvert()
addNewAdvert()
addNewAdvert()

© Bennett, McRobb and Farmer 2002 20


Handling Complexity
:Client :Campaign :Advert

*getClient()

listCampaigns()
*getCampaignDetails()
These flows are
continued
from the previous
figure listAdverts() *getAdvertDetails()

addNewAdvert()
newAd:Advert
Advert()

© Bennett, McRobb and Farmer 2002 21


Object Grouping
:Client CampaignAdverts
Campaign Lifeline
Manager representing a
getName() set of objects

listCampaigns()

checkCampaignBudget()

© Bennett, McRobb and Farmer 2002 22


Collaboration 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
© Bennett, McRobb and Farmer 2002 23
Collaboration Diagrams
One allocation of responsibilities for use case
Add a new advert to a campaign

5: createNewAdvert() 5.1: addNewAdvert()


4: selectCampaign() 4.1: showCampaignAdverts()
3: selectClient() 3.1: showClientCampaigns()

:AddAdvertUI :AddAdvert newAd:Advert

Campaign 5.1.1: addNewAdvert()


2: startInterface()
Manager 4.1.1: listAdverts()
1:*getClient() [Link]: Advert()
3.1.1: listCampaigns()

[Link]: *getCampaignDetails() [Link]: *getAdvertDetails()


:Client :Campaign :Advert

© Bennett, McRobb and Farmer 2002 24


Collaboration Diagrams
Alternative allocation of responsibilities for
use case
Add a new advert to a campaign
5: createNewAdvert() 5.1: addNewAdvert()
4: selectCampaign() 4.1: showCampaignAdverts()
3: selectClient() 3.1: showClientCampaigns() 4.1.2: *getAdvertDetails()

:AddAdvertUI :AddAdvert :Advert

Campaign 5.1.1: addNewAdvert()


2: startInterface()
Manager 4.1.1: listAdverts()
3.1.2: *getCampaignDetails()
1:*getClient()
3.1.1: listCampaigns()

[Link]: Advert()
:Client :Campaign newAd:Advert

© Bennett, McRobb and Farmer 2002 25


e
Labels Type of message Syntax example

Simple message. 4: addNewAdvert()

Nested call with return value.


The return value is placed in the 3.1.2: name:= getName()
variable name.

Conditional message.
This message is only sent if the [balance > 0] 5:
condition [balance > 0] is debit(amount)
true.

Synchronization with other


threads. 3.1a, 3. 1b / 4:playVideo()
Message 4: playVideo() is
invoked only once the two
concurrent messages 3.1a and
3.1b are completed.

© Bennett, McRobb and Farmer 2002 26


Navigating Links

© Bennett, McRobb and Farmer 2002 27


Model Consistency
 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
 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

© Bennett, McRobb and Farmer 2002 28


Model Consistency
 If both sequence and collaboration
diagrams are prepared they should be
consistent
 Messages on interaction diagrams must
be consistent with the statecharts for
the participating objects
 Implicit state changes in interaction
diagrams must be consistent with those
explicitly modelled in statecharts
© Bennett, McRobb and Farmer 2002 29
Summary
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
 How to cross-check between interaction
diagrams and a class diagram
© Bennett, McRobb and Farmer 2002 30
References
 UML Reference Manual (OMG,
2001)
(For full bibliographic details, see Bennett,
McRobb and Farmer)

© Bennett, McRobb and Farmer 2002 31

You might also like