Object diagrams

Interaction Diagrams
Spring 2001
Kyung Hee
University
1
Introduction
 Class diagrams
are used to specify the static structure of a system
 Object diagrams
are used to illustrate potential states of the system
are typically used only for illustrative purposes
 To specify an interaction, it must be stated which
messages will be sent, in which order, and under which
circumstances.
collaboration diagrams and sequence diagrams are referred to as
interaction diagrams
two types of diagram provide alternative ways of expressing the
same information
Kyung Hee
University
2
Collaborations
 Interactions are illustrated by adding messages to an
object diagram
 In order to achieve the required generality, interaction
diagram in UML are based on the general notion of a
collaboration, rather than on object diagrams.
 A collaboration is a general description of the ways in which
objects can be linked together in order to support the
behavior to be supported.
 Collaborations are related to class diagrams, as both of
them specify ways in which objects can be linked together.
Kyung Hee
University
3
Collaborations (cont’d)
 Collaborations specify only those which are relevant to a
particular type of interaction.
whereas class diagrams specify all the possible object structures in
a system
 Collaborations are defined not simply in terms of classes,
but rather in terms of the roles that instances of those
classes can play in various interactions
Kyung Hee
University
4
Classifier Roles
 Collaborations consists of roles
 A role describes a particular way in which an object can
participate in an interaction.
 A classifier role describes a role that objects can play in
interactions
 Notation for a classifier role : the name of the role and its
base class
Kyung Hee
University
5
Association Roles
 A collaboration consists of a number of classifier roles
connected by association roles
It consists of three classifier roles, linked by two association
roles

for finding the cost of a part in the stock control program
Kyung Hee
University
6
Transient Links
 An association between two classes implies that instances
of the classes can be linked and messages sent between
them.
 Short lived links are known as transient links
situations in which objects are able to communicate
to distinguish transient links from links that are instances of
associations.
Kyung Hee
University
7
Transient Links
 Parameter ‘part’ is used as the name of the corresponding
classifier role, and the association role connecting to the
assembly object is labeled with the appropriate stereotype
to indicate that this link exists because of the parameter that
was passed.
Kyung Hee
University
8
Interaction Diagram
 Sequence diagram
showing classifier roles only, but making the sequencing of
messages very clear.
 Collaboration diagram
showing classifier and association roles, and superimposing
messages on association roles
 The major difference between the two forms of diagram
is the way they show the order in which message are
sent.
Kyung Hee
University
9
Sequence Diagrams
 The classifier roles involved in the interaction are displayed at the
top of the diagram
Each role has a dashed line, known as its lifeline
Activation : the period of time during which an object is processing a
message designated as a narrow rectangle whose top is connected to a
message.
Kyung Hee
University
10
Collaboration Diagrams
 Unlike sequence diagram, collaboration diagrams show
association as well as classifier roles
messages sequencing cannot be shown graphically
Kyung Hee
University
11
Collaboration Diagrams (cont’d)
 Hierarchical numbering of messages
reflecting explicitly the structure of nested activations
Kyung Hee
University
12
Object Creation
The relationship between orders and order lines is one of
composition, because we assume that when an order is destroyed
all lines of that order are also destroyed.
Kyung Hee
University
13
Object Creation (cont’d)
 Object creation on a sequence diagram
Kyung Hee
University
14
Object Creation (cont’d)
 Object creation on a collaboration diagram
In order to distinguish elements that are created during the course
of an interaction from those which existed at the start, classifier and
association roles corresponding to new objects and links are
annotated with the property ‘new’.
Kyung Hee
University
15
Object Destruction
 Messages which cause the destruction of objects are
labeled with the stereotype ‘destroy’.
Kyung Hee
University
16
Object Destruction (cont’d)
 Object deletion on a collaboration diagram
Kyung Hee
University
17
Iterated Messages
 Showing a collaboration which uses this notation to show
that an assembly involved in an interaction can contain zero
or more components.
 Classifier roles and multiplicity
Kyung Hee
University
18
Iterated Messages (cont’d)
 In order to find out the cost of an assembly, a message must be sent to
each of the components, no matter how many there are.
 To emphasize the fact that a single symbol could correspond to multiple
messages, notation is added to message label to indicate an iterated
message send.
 Iterated message
passing on a collaboration
diagram
Kyung Hee
University
19
Iterated Messages (cont’d)
 Iteration diagram passing on a collaboration diagram
Kyung Hee
University
20
Multiobjects
 An alternative way of showing multiplicity information
associated with a classifier role is to use a multiobject.
a multipoint represents a collection of objects of the base type of the
multiobject
 Showing multiplicity with a multiobject
Kyung Hee
University
21
Multiobjects (cont’d)
 Showing an order object sending a message to a collection
of order lines, asking for the line which corresponds to the
catalogue entry with part number ‘n’.
Kyung Hee
University
22
Multiobjects (cont’d)
 Finding the total cost of an order
Kyung Hee
University
23
Conditional Messages
 A boolean expression written in square brackets
Kyung Hee
University
24
Conditional Messages (cont’d)
 Condition messages on collaboration diagrams
Kyung Hee
University
25
Conditional Messages (cont’d)
 Alternative messages on a sequence diagram
Kyung Hee
University
26
Conditional Messages (cont’d)
 Messages to Self
Kyung Hee
University
27
Conditional Messages (cont’d)
Recursive activations are not shown so explicitly on collaboration
diagram but, each recursive activation gives rise to an extra level of
hierarchy in the numbering of subsequent messages
Kyung Hee
University
28