Lecture 7
Lecture 7
BEHAVIOUR
Dr. Salome Maro
30th May 2022
RECAP
UML AND BEHAVIOUR
MODELLING
UML gives 3 diagrams to model system behaviour:
State machines
Activity diagrams
Interaction diagrams
UML AND BEHAVIOUR
MODELLING
UML gives 3 diagrams to model system behaviour:
State machines
Activity diagrams
Interaction diagrams
UML AND BEHAVIOUR
MODELLING
UML gives 3 diagrams to model system behaviour:
State machines
Activity diagrams
Interaction diagrams
INTERACTION DIAGRAMS
UML provides four types of interaction diagrams:
The sequence diagram, which shows objects interacting along lifelines that
represent general order.
The communication diagram shows the messages passed between objects,
focusing on the internal structure of the objects.
The interaction overview diagram treats a sequence diagrams as the unit
for a modified activity diagram that does not show any of the interaction
details.
The timing diagram shows interactions with a precise time axis.
INTERACTION DIAGRAMS
UML provides four types of interaction diagrams:
The sequence diagram, which shows objects interacting along lifelines that
represent general order.
The communication diagram shows the messages passed between objects,
focusing on the internal structure of the objects.
INTERACTION DIAGRAMS
UML provides four types of interaction diagrams:
The sequence diagram, which shows objects interacting along lifelines that
represent general order.
The communication diagram shows the messages passed between objects,
focusing on the internal structure of the objects.
COMMUNICATION DIAGRAMS
A.k.a Collaboration diagrams
COLLABORATION
DIAGRAMS
A Collaboration diagram is a graph showing a number of objects and the links
between them, which in addition shows the messages that, are passed from
one object to another.
Objects are placed on the page in a way that best supports showing their
relation to one another
Messages are shown as lines between the actual objects; therefore, the
messages show how the objects are related to each other.
COLLABORATION DIAGRAMS
COLLABORATION DIAGRAMS
Message
Demo Collaboration
Objects
Objects
Link line
Direction of message
ELEMENTS OF A
COLLABORATION DIAGRAM
Object: The objects interacting with each other in the
system. Depicted by a rectangle with the name of the
object in it, preceded by a colon and underlined. :ObjectName
makePayment(cashTendered) 1: makePayment(cashTendered)
: Register :Sale
PAYMENT : Register
2. The Register instance sends the
COLLABOR 1: makePayment(cashTendered)
makePayment message to a Sale
instance.
ATION
DIAGRAM :Sale 3. The Sale instance creates an
instance of a Payment.
1.1: create(cashTendered)
:Payment
MESSAGES TO “SELF” OR
“THIS”
A message can be sent from an object to itself.
This is illustrated by a link to itself, with messages flowing along the link.
msg1()
: Register
1: clear()
CONDITIONAL MESSAGES
A conditional message is shown by following a sequence number with a
conditional clause in square brackets, similar to the iteration clause.
The message is sent only if the clause evaluates to true.
makeNewSale()
2: msg6()
1a [test1] : msg2()
msg1()
:ClassA :ClassB
1b.1: msg5()
:ClassD :ClassC
ITERATION OR LOOPING
Iteration is indicated by following the sequence number with a star *
This expresses that the message is being sent repeatedly, in a loop, to the
receiver.
It is also possible to include an iteration clause indicating the recurrence
values.
runSimulation() 1 * [i:=1..N]: num := nextInt()
: Simulator : Random