SlideShare a Scribd company logo
Software and Services research group (S2)
Department of Computer Science, Faculty of Sciences
Vrije Universiteit Amsterdam
VRIJE
UNIVERSITEIT
AMSTERDAM
Modeling behaviour via
UML state machines
Software modeling (401016) – 2016/2017
Ivano Malavolta
i.malavolta@vu.nl
VRIJE
UNIVERSITEIT
AMSTERDAM
Roadmap
• Class diagram exercise
• State machine diagrams
• Introduction
• States
• Transitions
• Types of events
• Types of states
• Entry and exit points
2
VRIJE
UNIVERSITEIT
AMSTERDAM
Recall
3
VRIJE
UNIVERSITEIT
AMSTERDAM
Exercise
1. Analyze the following system
2. Select 5 functionalities that you know from using the
system
3. Define a class diagram describing data and operations
behind the 5 functionalities
67
Exercise inspired by prof. Lago’s lecture at the VU
VRIJE
UNIVERSITEIT
AMSTERDAM
Introduction
§ Every object takes a finite set of different states during its life
§ State machine diagram is used as follows:
§ to model the possible states of a system or object
§ to show how state transitions occur as a consequence of events
§ to show what behavior the system or object exhibits in each state
§ Example
§ high-level description of the behavior of a lecture hall
Transition State
4
VRIJE
UNIVERSITEIT
AMSTERDAM
Example: Lecture Hall with Details
class LectureHall {
private boolean free;
public void occupy() {
free=false;
}
public void release() {
free=true;
}
}
5
VRIJE
UNIVERSITEIT
AMSTERDAM
Example: Digital Clock
6
VRIJE
UNIVERSITEIT
AMSTERDAM
State
§States = nodes of the state machine
§When a state is active
§ The object is in that state
§ All internal activities specified in this state can
be executed
§entry / Activity(...)
§ Executed when the object enters the state
§exit / Activity(...)
§ Executed when the object exits the state
§do / Activity(...)
§ Executed while the object remains in this
state
7
VRIJE
UNIVERSITEIT
AMSTERDAM
Transition
Change from one state to another
Source state Target stateTransition
Event Guard Sequence of actions (effect)
8
VRIJE
UNIVERSITEIT
AMSTERDAM
Transition – Syntax
§ Event (trigger)
§ Can trigger a state transition
§ Guard (condition)
§ Boolean expression
§ If the event occurs, the guard is checked
§ If the guard is true
1. All activities in the current state are terminated
2. Any relevant exit activity is executed
3. The transition takes place
§ If the guard is false
§ No state transition takes place, the event is discarded
§ Activity (effect)
§ Sequence of actions executed during the state transition
9
VRIJE
UNIVERSITEIT
AMSTERDAM
Transition – Types (1/2)
Internal transition External transition
§ If event1 occurs
§ Object remains in state1
§ Activity3 is executed
§ If event1 occurs
§ Object leaves state1 and
Activity2 is executed
§ Activity3 is executed
§ Object enters state1 and
Activity1 is executed
10
VRIJE
UNIVERSITEIT
AMSTERDAM
Transition – Types (2/2)
§ When do the following transitions take place?
If e1 occurs, A1 is aborted and the object
changes to S2
If e1 occurs and g1 evaluates to true, A1 is
aborted and the object changes to S2
As soon as the execution of A1 is finished, a
completion event is generated that initiates the
transition to S2
As soon as the execution of A1 is finished, a
completion event is generated; if g1 evaluates to
true, the transition takes place; If not, this
transition can never happen
11
VRIJE
UNIVERSITEIT
AMSTERDAM
Transition – Sequence of Activity Executions
Assume S1 is active … what is the value of x after e occurred?
S1 becomes active, x is set to the value 4
S1 is left, x is set to 5
e occurs, the guard is checked and evaluates to true
The transition takes place, x is set to 10
S2 is entered, x is set to 11
12
VRIJE
UNIVERSITEIT
AMSTERDAM
Event – Types (1/2)
§ Signal event
Receipt of a signal
§ E.g., rightmousedown, sendSMS(message)
§ Call event
Operation call
§ E.g., occupy(user,lectureHall), register(exam)
§ Time event
Time-based state transition
§ Relative: based on the time of the occurrence of the event
§ E.g., after(5 seconds)
§ Absolute
§ E.g., when(time==16:00), when(date==20150101)
13
VRIJE
UNIVERSITEIT
AMSTERDAM
Event – Types (2/2)
§ Any receive event
§ Occurs when any event occurs that does not trigger another
transition from the active state
§ Keyword all
§ Completion event
§ Generated automatically when everything to be done in the
current state is completed
§ Change event
§ Permanently checking whether a condition becomes true
§ E.g., when(x > y), after(90min)
VRIJE
UNIVERSITEIT
AMSTERDAM
Change Event vs. Guard
Checked permanently
Only checked when event occurs
Question: What if the lecture is shorter than 90min? 15
VRIJE
UNIVERSITEIT
AMSTERDAM
Initial State
§ “Start” of a state machine diagram
§ Pseudostate
§ Transient, i.e., system cannot remain in that state
§ Rather a control structure than a real state
§ No incoming edges
§ If >1 outgoing edges
§ Guards must be mutually exclusive and cover all possible cases
to ensure that exactly one target state is reached
§ If initial state becomes active, the object immediately switches
to the next state
§ No events allowed on the outgoing edges (exception: new())
16
VRIJE
UNIVERSITEIT
AMSTERDAM
Final State and Terminate Node
Final State
§ Real state
§ Marks the end of the sequence of states
§ Object can remain in a final state forever
Terminate Node
§ Pseudostate
§ Terminates the state machine
§ The modeled object ceases to exist (= is deleted)
17
VRIJE
UNIVERSITEIT
AMSTERDAM
Decision Node
§ Pseudostate
§ Used to model alternative transitions
equivalent?
=
≠
equivalent?
18
VRIJE
UNIVERSITEIT
AMSTERDAM
Example: Decision Node
19
VRIJE
UNIVERSITEIT
AMSTERDAM
Parallelization and Synchronization Node
Parallelization node
§ Pseudostate
§ Splits the control flow into multiple concurrent flows
§ 1 incoming edge
§ >1 outgoing edges
Synchronization node
§ Pseudostate
§ Merges multiple concurrent flows
§ >1 incoming edges
§ 1 outgoing edge
20
VRIJE
UNIVERSITEIT
AMSTERDAM
Composite State
§Contains other states – “substates“
§ Only one of its substates is active at any point in time
§ Arbitrary nesting depth of substates
Composite state
Substates
21
VRIJE
UNIVERSITEIT
AMSTERDAM
Entering a Composite State (1/2)
§ Transition to the boundary
§ Initial node of composite
state is activated
Event State Executed
Activities
„Beginning“ S3
e2 S1/S1.1 a0-a2-a3-a4
22
VRIJE
UNIVERSITEIT
AMSTERDAM
Entering a Composite State (2/2)
§Transition to a substate
§ Substate is activated
Event State Executed
Activities
„Beginning“ S3
e1 S1/S1.2 a0-a1-a3-a7
2323
VRIJE
UNIVERSITEIT
AMSTERDAM
Exiting from a Composite State (1/3)
§Transition from a substate Event State Executed
Activities
„Beginning“ S1/S1.1 a3-a4
e3 S2 a6-a5-a2-a1
24
VRIJE
UNIVERSITEIT
AMSTERDAM
Event State Executed
Activities
„Beginning“ S1/S1.1 a3-a4
e5 S2 a6-a5-a3-a1
Exiting from a Composite State (2/3)
§Transition from the composite state
No matter which substate of S1
is active, as soon as e5 occurs,
the system changes to S2
25
VRIJE
UNIVERSITEIT
AMSTERDAM
Event State Executed
Activities
„Beginning“ S1/S1.1 a3-a4
e4 S1/S1.2 a6-a7
e4 S2 a8-a5-a1
Exiting from a Composite State (3/3)
§Completion transition from
the composite state
26
VRIJE
UNIVERSITEIT
AMSTERDAM
Orthogonal State
§ Composite state is divided into two or more regions separated
by a dashed line
§ One state of each region is always active at any point in time,
i.e., concurrent substates
§ Entry: transition to the boundary of the orthogonal state
activates the initial states of all regions
§ Exit: final state must be reached in all regions to trigger
completion event
You can use parallelization and
synchronization node to enter
different substates
27
VRIJE
UNIVERSITEIT
AMSTERDAM
Submachine State (SMS)
§ To reuse parts of state machine diagrams in other state
machine diagrams
§ Notation: state:submachineState
§ As soon as the submachine state is activated, the behavior of
the submachine is executed
§ Corresponds to calling a subroutine in programming languages
28
Refinement symbol
(optional)
VRIJE
UNIVERSITEIT
AMSTERDAM
History State
§ Remembers which substate of a composite state was the last
active one
§ Activates the “old” substate and all entry activities are
conducted sequentially from the outside to the inside of the
composite state
§ Exactly one outgoing edge of the history state points to a
substate. It is used if:
§ the composite state was never active before
§ the composite state was exited via the final state
§ Shallow history state restores the state that is on the same
level of the composite state
§ Deep history state restores the last active substate over the
entire nesting depth
29
VRIJE
UNIVERSITEIT
AMSTERDAM
Example: History State (1/4)
Event State
„Beginning“ S5
e1 S4/S1/S1.1
e2 S1.2
e10 S5
e9 (H→) S1/S1.1
30
VRIJE
UNIVERSITEIT
AMSTERDAM
Example: History State (2/4)
Event State
„Beginning“ S5
e1 S4/S1/S1.1
e2 S1.2
e10 S5
e8 (H*→) S1.2
31
VRIJE
UNIVERSITEIT
AMSTERDAM
Example: History State (3/4)
Event State
„Beginning“ S5
e9 (H→) S1/S1.1
32
VRIJE
UNIVERSITEIT
AMSTERDAM
Example: History State (4/4)
Event State
„Beginning“ S5
e8 (H*→) S3/S3.1
33
VRIJE
UNIVERSITEIT
AMSTERDAM
Entry and Exit Points
§ Encapsulation mechanism
§ A composite state shall be entered or exited via a state other
than the initial and final states
§ The external transition must/need not know the structure of the
composite state
External view
34
Internal view
VRIJE
UNIVERSITEIT
AMSTERDAM
Notation Elements (1/2)
Name Notation Description
State
Description of a specific “time span” in
which an object finds itself during its
“life cycle”. Within a state, activities
can be executed by the object.
Transition
State transition e from a source state S
to a target state T
Initial state Start of a state machine diagram
Final state End of a state machine diagram
Terminate node
Termination of an object’s state
machine diagram
35
VRIJE
UNIVERSITEIT
AMSTERDAM
Notation Elements (2/2)
Name Syntax Beschreibung
Decision node
Node from which multiple alternative
transitions can origin
Parallelization node
Splitting of a transition into multiple
parallel transitions
Synchronization
node
Merging of multiple parallel transitions
into one transition
Shallow / deep
history state
“Return address” to a substate or a
nested substate of a composite state
36
VRIJE
UNIVERSITEIT
AMSTERDAM
Exercise
Event sequence: e1, e2, e4, e4, e3, e1
Value of x?
37
VRIJE
UNIVERSITEIT
AMSTERDAM
Solution
38
VRIJE
UNIVERSITEIT
AMSTERDAM
What this lecture means to you?
• Your models are starting to move now!
• State machine used for modelling the internal states of each
object in your system
• In principles, you will have a state machine for each class in
your class diagrams
• do not take it literally
• you may need less
• the operator is human à you may not need to program it!
• you model only the key states of the objects, not everything
39
VRIJE
UNIVERSITEIT
AMSTERDAM
Readings
• UML@Classroom: An Introduction to Object-Oriented
Modeling” – chapter 5
• Learning UML 2.0 – chapter 14
• TOOL guide
• https://www.itemis.com/en/yakindu/statechart-
tools/documentation/user-guide/
40

More Related Content

PDF
Introduction to React Hooks
DOCX
Website requirements and planning document
PPTX
HOTEL MANAGEMENT SYSTEM
PPTX
Hotel online booking
PPTX
Student Management System Project Abstract
PDF
React&redux
PDF
Crime file
DOCX
Synopsis of yashbazaar.com
 
Introduction to React Hooks
Website requirements and planning document
HOTEL MANAGEMENT SYSTEM
Hotel online booking
Student Management System Project Abstract
React&redux
Crime file
Synopsis of yashbazaar.com
 

What's hot (9)

PPTX
Oracle Endeca Developer's Guide
PPTX
Its time to React.js
PDF
React
PDF
JSON Web Tokens
PPTX
Reactjs
PPTX
React hooks
PDF
Single page applications
DOCX
Software engineering project(srs)!!
PPTX
REST Easy with Django-Rest-Framework
Oracle Endeca Developer's Guide
Its time to React.js
React
JSON Web Tokens
Reactjs
React hooks
Single page applications
Software engineering project(srs)!!
REST Easy with Django-Rest-Framework
Ad

Viewers also liked (20)

PDF
Object-oriented design patterns in UML [Software Modeling] [Computer Science...
PDF
Modeling objects interaction via UML sequence diagrams [Software Modeling] [...
PDF
Structure modeling with UML [Software Modeling] [Computer Science] [Vrije Uni...
PDF
Requirements engineering with UML [Software Modeling] [Computer Science] [Vri...
PDF
Modeling and abstraction, software development process [Software Modeling] [C...
PPTX
Computer science curriculum based on Program learning outcomes and objectives
PDF
[2016/2017] Modern development paradigms
PDF
[2016/2017] Introduction to Software Architecture
PDF
Mission planning of autonomous quadrotors
PDF
[2016/2017] AADL (Architecture Analysis and Design Language)
PDF
[2016/2017] Architectural languages
PDF
Beyond Native Apps: Web Technologies to the Rescue! [SPLASH 2016 - Mobile! k...
PDF
[2016/2017] RESEARCH in software engineering
PDF
Mobile Applications Development - Lecture 0
PDF
Web-based Hybrid Mobile Apps: State of the Practice and Research opportunitie...
PDF
Leveraging Web Analytics for Automatically Generating Mobile Navigation Model...
PDF
The Green Lab - [13 B] Future research challenges
PPTX
PDF
The road ahead for architectural languages [ACVI 2016]
PPTX
1.4 Análisis y Diseño de Sistemas
Object-oriented design patterns in UML [Software Modeling] [Computer Science...
Modeling objects interaction via UML sequence diagrams [Software Modeling] [...
Structure modeling with UML [Software Modeling] [Computer Science] [Vrije Uni...
Requirements engineering with UML [Software Modeling] [Computer Science] [Vri...
Modeling and abstraction, software development process [Software Modeling] [C...
Computer science curriculum based on Program learning outcomes and objectives
[2016/2017] Modern development paradigms
[2016/2017] Introduction to Software Architecture
Mission planning of autonomous quadrotors
[2016/2017] AADL (Architecture Analysis and Design Language)
[2016/2017] Architectural languages
Beyond Native Apps: Web Technologies to the Rescue! [SPLASH 2016 - Mobile! k...
[2016/2017] RESEARCH in software engineering
Mobile Applications Development - Lecture 0
Web-based Hybrid Mobile Apps: State of the Practice and Research opportunitie...
Leveraging Web Analytics for Automatically Generating Mobile Navigation Model...
The Green Lab - [13 B] Future research challenges
The road ahead for architectural languages [ACVI 2016]
1.4 Análisis y Diseño de Sistemas
Ad

Similar to Modeling behaviour via UML state machines [Software Modeling] [Computer Science] [Vrije Universiteit Amsterdam] [2016/2017] (15)

PDF
Modeling behaviour via UML state machines [Software Design] [Computer Science...
PDF
Software Engineering :Behavioral Modelling - II State diagram
PPTX
State modeling
PPTX
STATE DIAGRAM.pptx
PPTX
state modeling In UML
PPT
State Diagrams
PPTX
OOAD___Advanced Behavioral Modeling.pptx
PPTX
events and signals in Unified modelling language
PDF
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...
PPT
Seminar State Chart1
PPTX
Diagrams
PPTX
Programming models for event controlled programs
PPTX
05_ActivityDiagram_slides_2015.pptx
PPTX
Flink Forward Berlin 2017: Kostas Kloudas - Complex Event Processing with Fli...
PPTX
TLA+ and PlusCal / An engineer's perspective
Modeling behaviour via UML state machines [Software Design] [Computer Science...
Software Engineering :Behavioral Modelling - II State diagram
State modeling
STATE DIAGRAM.pptx
state modeling In UML
State Diagrams
OOAD___Advanced Behavioral Modeling.pptx
events and signals in Unified modelling language
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...
Seminar State Chart1
Diagrams
Programming models for event controlled programs
05_ActivityDiagram_slides_2015.pptx
Flink Forward Berlin 2017: Kostas Kloudas - Complex Event Processing with Fli...
TLA+ and PlusCal / An engineer's perspective

More from Ivano Malavolta (20)

PDF
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
PDF
Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...
PDF
The H2020 experience
PDF
The Green Lab - Research cocktail @Vrije Universiteit Amsterdam (October 2020)
PDF
Software sustainability and Green IT
PDF
Navigation-aware and Personalized Prefetching of Network Requests in Android ...
PDF
How Maintainability Issues of Android Apps Evolve [ICSME 2018]
PDF
Collaborative Model-Driven Software Engineering: a Classification Framework a...
PDF
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...
PDF
Object-oriented design patterns in UML [Software Design] [Computer Science] [...
PDF
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...
PDF
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...
PDF
Modeling and abstraction, software development process [Software Design] [Com...
PDF
[2017/2018] Agile development
PDF
Reconstructing microservice-based architectures
PDF
[2017/2018] AADL - Architecture Analysis and Design Language
PDF
[2017/2018] Architectural languages
PDF
[2017/2018] Introduction to Software Architecture
PDF
[2017/2018] RESEARCH in software engineering
PDF
Mobile Apps quality - a tale about energy, performance, and users’ perception
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...
The H2020 experience
The Green Lab - Research cocktail @Vrije Universiteit Amsterdam (October 2020)
Software sustainability and Green IT
Navigation-aware and Personalized Prefetching of Network Requests in Android ...
How Maintainability Issues of Android Apps Evolve [ICSME 2018]
Collaborative Model-Driven Software Engineering: a Classification Framework a...
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...
Object-oriented design patterns in UML [Software Design] [Computer Science] [...
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...
Modeling and abstraction, software development process [Software Design] [Com...
[2017/2018] Agile development
Reconstructing microservice-based architectures
[2017/2018] AADL - Architecture Analysis and Design Language
[2017/2018] Architectural languages
[2017/2018] Introduction to Software Architecture
[2017/2018] RESEARCH in software engineering
Mobile Apps quality - a tale about energy, performance, and users’ perception

Recently uploaded (20)

PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Getting Started with Data Integration: FME Form 101
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPT
Teaching material agriculture food technology
PDF
Machine learning based COVID-19 study performance prediction
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
1. Introduction to Computer Programming.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Machine Learning_overview_presentation.pptx
Group 1 Presentation -Planning and Decision Making .pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Mobile App Security Testing_ A Comprehensive Guide.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Getting Started with Data Integration: FME Form 101
Reach Out and Touch Someone: Haptics and Empathic Computing
Teaching material agriculture food technology
Machine learning based COVID-19 study performance prediction
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
MYSQL Presentation for SQL database connectivity
1. Introduction to Computer Programming.pptx
Big Data Technologies - Introduction.pptx
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
NewMind AI Weekly Chronicles - August'25-Week II
Per capita expenditure prediction using model stacking based on satellite ima...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Machine Learning_overview_presentation.pptx

Modeling behaviour via UML state machines [Software Modeling] [Computer Science] [Vrije Universiteit Amsterdam] [2016/2017]

  • 1. Software and Services research group (S2) Department of Computer Science, Faculty of Sciences Vrije Universiteit Amsterdam VRIJE UNIVERSITEIT AMSTERDAM Modeling behaviour via UML state machines Software modeling (401016) – 2016/2017 Ivano Malavolta [email protected]
  • 2. VRIJE UNIVERSITEIT AMSTERDAM Roadmap • Class diagram exercise • State machine diagrams • Introduction • States • Transitions • Types of events • Types of states • Entry and exit points 2
  • 3. VRIJE UNIVERSITEIT AMSTERDAM Recall 3 VRIJE UNIVERSITEIT AMSTERDAM Exercise 1. Analyze the following system 2. Select 5 functionalities that you know from using the system 3. Define a class diagram describing data and operations behind the 5 functionalities 67 Exercise inspired by prof. Lago’s lecture at the VU
  • 4. VRIJE UNIVERSITEIT AMSTERDAM Introduction § Every object takes a finite set of different states during its life § State machine diagram is used as follows: § to model the possible states of a system or object § to show how state transitions occur as a consequence of events § to show what behavior the system or object exhibits in each state § Example § high-level description of the behavior of a lecture hall Transition State 4
  • 5. VRIJE UNIVERSITEIT AMSTERDAM Example: Lecture Hall with Details class LectureHall { private boolean free; public void occupy() { free=false; } public void release() { free=true; } } 5
  • 7. VRIJE UNIVERSITEIT AMSTERDAM State §States = nodes of the state machine §When a state is active § The object is in that state § All internal activities specified in this state can be executed §entry / Activity(...) § Executed when the object enters the state §exit / Activity(...) § Executed when the object exits the state §do / Activity(...) § Executed while the object remains in this state 7
  • 8. VRIJE UNIVERSITEIT AMSTERDAM Transition Change from one state to another Source state Target stateTransition Event Guard Sequence of actions (effect) 8
  • 9. VRIJE UNIVERSITEIT AMSTERDAM Transition – Syntax § Event (trigger) § Can trigger a state transition § Guard (condition) § Boolean expression § If the event occurs, the guard is checked § If the guard is true 1. All activities in the current state are terminated 2. Any relevant exit activity is executed 3. The transition takes place § If the guard is false § No state transition takes place, the event is discarded § Activity (effect) § Sequence of actions executed during the state transition 9
  • 10. VRIJE UNIVERSITEIT AMSTERDAM Transition – Types (1/2) Internal transition External transition § If event1 occurs § Object remains in state1 § Activity3 is executed § If event1 occurs § Object leaves state1 and Activity2 is executed § Activity3 is executed § Object enters state1 and Activity1 is executed 10
  • 11. VRIJE UNIVERSITEIT AMSTERDAM Transition – Types (2/2) § When do the following transitions take place? If e1 occurs, A1 is aborted and the object changes to S2 If e1 occurs and g1 evaluates to true, A1 is aborted and the object changes to S2 As soon as the execution of A1 is finished, a completion event is generated that initiates the transition to S2 As soon as the execution of A1 is finished, a completion event is generated; if g1 evaluates to true, the transition takes place; If not, this transition can never happen 11
  • 12. VRIJE UNIVERSITEIT AMSTERDAM Transition – Sequence of Activity Executions Assume S1 is active … what is the value of x after e occurred? S1 becomes active, x is set to the value 4 S1 is left, x is set to 5 e occurs, the guard is checked and evaluates to true The transition takes place, x is set to 10 S2 is entered, x is set to 11 12
  • 13. VRIJE UNIVERSITEIT AMSTERDAM Event – Types (1/2) § Signal event Receipt of a signal § E.g., rightmousedown, sendSMS(message) § Call event Operation call § E.g., occupy(user,lectureHall), register(exam) § Time event Time-based state transition § Relative: based on the time of the occurrence of the event § E.g., after(5 seconds) § Absolute § E.g., when(time==16:00), when(date==20150101) 13
  • 14. VRIJE UNIVERSITEIT AMSTERDAM Event – Types (2/2) § Any receive event § Occurs when any event occurs that does not trigger another transition from the active state § Keyword all § Completion event § Generated automatically when everything to be done in the current state is completed § Change event § Permanently checking whether a condition becomes true § E.g., when(x > y), after(90min)
  • 15. VRIJE UNIVERSITEIT AMSTERDAM Change Event vs. Guard Checked permanently Only checked when event occurs Question: What if the lecture is shorter than 90min? 15
  • 16. VRIJE UNIVERSITEIT AMSTERDAM Initial State § “Start” of a state machine diagram § Pseudostate § Transient, i.e., system cannot remain in that state § Rather a control structure than a real state § No incoming edges § If >1 outgoing edges § Guards must be mutually exclusive and cover all possible cases to ensure that exactly one target state is reached § If initial state becomes active, the object immediately switches to the next state § No events allowed on the outgoing edges (exception: new()) 16
  • 17. VRIJE UNIVERSITEIT AMSTERDAM Final State and Terminate Node Final State § Real state § Marks the end of the sequence of states § Object can remain in a final state forever Terminate Node § Pseudostate § Terminates the state machine § The modeled object ceases to exist (= is deleted) 17
  • 18. VRIJE UNIVERSITEIT AMSTERDAM Decision Node § Pseudostate § Used to model alternative transitions equivalent? = ≠ equivalent? 18
  • 20. VRIJE UNIVERSITEIT AMSTERDAM Parallelization and Synchronization Node Parallelization node § Pseudostate § Splits the control flow into multiple concurrent flows § 1 incoming edge § >1 outgoing edges Synchronization node § Pseudostate § Merges multiple concurrent flows § >1 incoming edges § 1 outgoing edge 20
  • 21. VRIJE UNIVERSITEIT AMSTERDAM Composite State §Contains other states – “substates“ § Only one of its substates is active at any point in time § Arbitrary nesting depth of substates Composite state Substates 21
  • 22. VRIJE UNIVERSITEIT AMSTERDAM Entering a Composite State (1/2) § Transition to the boundary § Initial node of composite state is activated Event State Executed Activities „Beginning“ S3 e2 S1/S1.1 a0-a2-a3-a4 22
  • 23. VRIJE UNIVERSITEIT AMSTERDAM Entering a Composite State (2/2) §Transition to a substate § Substate is activated Event State Executed Activities „Beginning“ S3 e1 S1/S1.2 a0-a1-a3-a7 2323
  • 24. VRIJE UNIVERSITEIT AMSTERDAM Exiting from a Composite State (1/3) §Transition from a substate Event State Executed Activities „Beginning“ S1/S1.1 a3-a4 e3 S2 a6-a5-a2-a1 24
  • 25. VRIJE UNIVERSITEIT AMSTERDAM Event State Executed Activities „Beginning“ S1/S1.1 a3-a4 e5 S2 a6-a5-a3-a1 Exiting from a Composite State (2/3) §Transition from the composite state No matter which substate of S1 is active, as soon as e5 occurs, the system changes to S2 25
  • 26. VRIJE UNIVERSITEIT AMSTERDAM Event State Executed Activities „Beginning“ S1/S1.1 a3-a4 e4 S1/S1.2 a6-a7 e4 S2 a8-a5-a1 Exiting from a Composite State (3/3) §Completion transition from the composite state 26
  • 27. VRIJE UNIVERSITEIT AMSTERDAM Orthogonal State § Composite state is divided into two or more regions separated by a dashed line § One state of each region is always active at any point in time, i.e., concurrent substates § Entry: transition to the boundary of the orthogonal state activates the initial states of all regions § Exit: final state must be reached in all regions to trigger completion event You can use parallelization and synchronization node to enter different substates 27
  • 28. VRIJE UNIVERSITEIT AMSTERDAM Submachine State (SMS) § To reuse parts of state machine diagrams in other state machine diagrams § Notation: state:submachineState § As soon as the submachine state is activated, the behavior of the submachine is executed § Corresponds to calling a subroutine in programming languages 28 Refinement symbol (optional)
  • 29. VRIJE UNIVERSITEIT AMSTERDAM History State § Remembers which substate of a composite state was the last active one § Activates the “old” substate and all entry activities are conducted sequentially from the outside to the inside of the composite state § Exactly one outgoing edge of the history state points to a substate. It is used if: § the composite state was never active before § the composite state was exited via the final state § Shallow history state restores the state that is on the same level of the composite state § Deep history state restores the last active substate over the entire nesting depth 29
  • 30. VRIJE UNIVERSITEIT AMSTERDAM Example: History State (1/4) Event State „Beginning“ S5 e1 S4/S1/S1.1 e2 S1.2 e10 S5 e9 (H→) S1/S1.1 30
  • 31. VRIJE UNIVERSITEIT AMSTERDAM Example: History State (2/4) Event State „Beginning“ S5 e1 S4/S1/S1.1 e2 S1.2 e10 S5 e8 (H*→) S1.2 31
  • 32. VRIJE UNIVERSITEIT AMSTERDAM Example: History State (3/4) Event State „Beginning“ S5 e9 (H→) S1/S1.1 32
  • 33. VRIJE UNIVERSITEIT AMSTERDAM Example: History State (4/4) Event State „Beginning“ S5 e8 (H*→) S3/S3.1 33
  • 34. VRIJE UNIVERSITEIT AMSTERDAM Entry and Exit Points § Encapsulation mechanism § A composite state shall be entered or exited via a state other than the initial and final states § The external transition must/need not know the structure of the composite state External view 34 Internal view
  • 35. VRIJE UNIVERSITEIT AMSTERDAM Notation Elements (1/2) Name Notation Description State Description of a specific “time span” in which an object finds itself during its “life cycle”. Within a state, activities can be executed by the object. Transition State transition e from a source state S to a target state T Initial state Start of a state machine diagram Final state End of a state machine diagram Terminate node Termination of an object’s state machine diagram 35
  • 36. VRIJE UNIVERSITEIT AMSTERDAM Notation Elements (2/2) Name Syntax Beschreibung Decision node Node from which multiple alternative transitions can origin Parallelization node Splitting of a transition into multiple parallel transitions Synchronization node Merging of multiple parallel transitions into one transition Shallow / deep history state “Return address” to a substate or a nested substate of a composite state 36
  • 39. VRIJE UNIVERSITEIT AMSTERDAM What this lecture means to you? • Your models are starting to move now! • State machine used for modelling the internal states of each object in your system • In principles, you will have a state machine for each class in your class diagrams • do not take it literally • you may need less • the operator is human à you may not need to program it! • you model only the key states of the objects, not everything 39
  • 40. VRIJE UNIVERSITEIT AMSTERDAM Readings • UML@Classroom: An Introduction to Object-Oriented Modeling” – chapter 5 • Learning UML 2.0 – chapter 14 • TOOL guide • https://www.itemis.com/en/yakindu/statechart- tools/documentation/user-guide/ 40