Lecture 6
Lecture 6
BEHAVIOR
Dr. Salome Maro
23rd May 2022
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
SYSTEM BEHAVIOR
State Machines: These describe which states an object can have during its life
cycle, and the behaviour in those states along with what events cause the state
to change;
for example, an invoice can be paid (state paid) or unpaid (state unpaid).
Activity diagrams: show communication in a system, but they focus on
workflow.
Interactions diagrams: describe how objects communicate with each other.
How and which messages and sent and received.
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.
SEQUENCE DIAGRAMS
Sequence diagrams illustrate how objects interact with each other.
They focus on message sequences, that is, how messages are sent and received
between a number of objects.
SEQUENCE DIAGRAMS
Show concurrent processes and activations
• Show time sequences that are not easily depicted in other diagrams
• Typically used during analysis and design to document and understand the
logical flow of your system
Method call
Execution
Lifeline
Return value
SEQUENCE DIAGRAM
Time Increasing -->
Generic (unnamed)
Specific Generic
objects(unnamed)
Instance of an objects of class type Seminar
Object and Course
COMPONENTS
execution
lifeline
COMPONENTS
Method call
Return value
SYNCHRONOUS VS
ASYNCHRONOUS MESSAGES
Synchronous message call : A message is sent from the source lifeline to the
target lifeline. The source lifeline is blocked from other operations until it
receives a response from the target lifeline.
Example: A bank teller might send a credit request to the bank manager for
approval and must wait for a response before further serving the customer.
SYNCHRONOUS VS
ASYNCHRONOUS MESSAGES
Asynchronous message call : The source lifeline is not blocked from receiving
or sending other messages. You can also move the send and receive points
individually to delay the time between the send and receive events. You might
choose to do this if a response is not time-sensitive or order- sensitive.
Example: A bank customer could apply for credit but can receive banking
information over the phone or request money from an ATM, while waiting to
hear about the credit application.
SEQUENCE FRAGMENTS
Sequence diagrams can be broken up into chunks called fragments.
These fragments are surrounded by a frame like the one around the whole
diagram.
the specifier in the upper-left corner represents an operator that prescribes how
the fragment is handled.
Fragments can have:
Alternatives
Loops
ALTERNATIVES
LOOPS
RECURSION
Objects can invoke its own operations
There must be a condition in the operation that stops the
recursion.
CLASS ACTIVITY
Draw a sequence diagram of withdrawing money from an ATM machine.
REFERENCES
Some slides borrowed from Dan Fleck
UML 2 Book
TEST 2
Thursday 26th May
Completely online
Time : 12:15 – 13:00 (Strict)
Any signs of copying will be penalized.
Attempt the pre-test on LMS to see if the test works well in your PC with the current security
features.