Professional Documents
Culture Documents
BEHAVIOR
Dr. Salome Maro
16th May 2022
SYSTEM BEHAVIOR
All systems have static structure and dynamic behavior;
Class diagrams are best used to document and express the static structure of a
system
Objects within systems communicate with each other; they send messages to
each other.
Describing the static structure of a system can reveal what the system contains
and how those things are related, but it does not explain how these things
cooperate to manage their tasks and provide the functionality of the system.
SYSTEM BEHAVIOR
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 behavior 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.
SYSTEM BEHAVIOR
Interaction and activity diagrams both show communication between objects
Interaction diagrams focus on the collaboration among the objects
Activity diagrams focus on set of actions occurring in a workflow
Class diagrams – Describe the structure of the system and are used in the
implementation of the use cases
State machines – Describes the state of the objects modelled in the class
diagrams
STATE MACHINES
All objects have a state
Examples of object states are:
The invoice (object) is paid (state).
The car (object) is standing still (state).
The engine (object) is running (state).
Kate (object) is married (state).
STATE MACHINES
An object transitions (changes) from one state to another state when
something happens, which is called an event;
Initial and Final States - The initial state is denoted by a filled black circle
and may be labeled with a name. The final state is denoted by a circle with a
dot inside and may also be labeled with a name.
STATE MACHINE DIAGRAMS
• Transitions - Transitions from one state to
the next are denoted by lines with
arrowheads.
State A
STATE MACHINE DIAGRAMS
A transition may have a trigger, a guard and an effect.
"Trigger" is the cause of the transition, which could be a signal, an event, a change in
some condition, or the passage of time. Example: Request received
"Guard" is a condition which must be true in order for the trigger to cause the
transition. Example: [t = 15sec], [number of invoices > n], withdrawal (amount)
[balance >= amount]
"Effect" is an action which will be invoked directly on the object that owns the state
machine as a result of the transition. Example: Send request or approve request
STATE MACHINES DIAGRAMS
Effect
STATE MACHINE DIAGRAMS
• State Actions - In the transition example above, an effect was associated with the transition. If the
target state had many transitions arriving at it, and each transition had the same effect associated
with it, it would be better to associate the effect with the target state rather than the transitions.
• It is also possible to define actions that occur on events, or actions that always occur. It is
possible to define any number of actions of each type.
Verify card