Download presentation
Presentation is loading. Please wait.
Published byEugene Day Modified over 6 years ago
1
CS251 – Software Engineering Lectures 11 State Diagrams
Read Reading 8 Chapter 8 (only 8.2) from OO SE 2/e, Slides by: Timothy Lethbridge
2
Chapter 5: Modelling with classes
Last Lecture Where are we now ? why Modeling software ? Sequence diagram ? Chapter 5: Modelling with classes © Lethbridge/Laganière 2012
3
Chapter 5: Modelling with classes
Outline State diagrams Modelling states and transitions Modelling activities and actions Examples Chapter 5: Modelling with classes © Lethbridge/Laganière 2012
4
Chapter 8: Modelling Interactions and Behaviour
8.2 State Diagrams A state diagram describes the behavior of a system, some part of a system, or an individual object. At any given point in time, the system or object is in a certain state. Being in a state means that it is will behave in a specific way in response to any events that occur. Some events will cause the system to change state. In the new state, the system will behave in a different way to events. A state diagram is a directed graph where the nodes are states and the arcs are transitions. Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005
5
State diagrams – an example
tic-tac-toe game Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005
6
State diagrams – an example
Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005
7
Chapter 8: Modelling Interactions and Behaviour
States At any given point in time, the system is in one state. A state is represented by a set of values for the attributes of the given object. It will remain in this state until an event occurs that causes it to change state. Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005
8
Chapter 8: Modelling Interactions and Behaviour
States A state is represented by a rounded rectangle containing the name of the state. Special states: A black circle represents the start state A circle with a ring around it represents an end state Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005
9
Chapter 8: Modelling Interactions and Behaviour
State Diagram States Transitions Events Activities Actions Initial state event transition state off hook Idle Active on hook Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005
10
Chapter 8: Modelling Interactions and Behaviour
Transitions A transition represents a change of state in response to an event. The label on each transition is the event that causes the change of state. Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005
11
Example dial tone dialling idle digit (n) on-hook off-hook on-hook
State Event Transition digit (n) digit (n) dial tone dialling on-hook off-hook on-hook idle
12
State diagrams – an example with conditional transitions
action condition
13
State diagrams – an example with conditional transitions
Add these info to the last state diagram (a) The course section can be canceled when in any state, except after it has been taught. (b) A student can drop out at any time, except after the course section has been taught.
14
Activities in state diagrams
An activity is something that takes place while the system is in a state. It takes a period of time. The system may take a transition out of the state in response to completion of the activity, Some other outgoing transition may result in: The interruption of the activity, and An early exit from the state. Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005
15
State diagram – an example with activity
Audio Playing Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005
16
Chapter 8: Modelling Interactions and Behaviour
Types of Events External Event (also known as system event) is caused by something outside the system boundary e.g. when a cashier presses the “enter item” button on a POST, an external event has occurred. Internal Event is caused by something inside our system boundary. In internal event arises when an operation is invoked via a message sent from another internal object. Temporal Event is caused by the occurrence of a specific date and time or passage of time. Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005
17
Actions in state diagrams
An action is something that takes place effectively instantaneously When a particular transition is taken, Upon entry into a particular state, or Upon exit from a particular state An action should consume no noticeable amount of time Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005
18
State diagram – an example with actions
Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005
19
Nested substates and guard conditions
A state diagram can be nested inside a state. The states of the inner diagram are called substates. Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005
20
State diagram – an example with substates
Chapter 8: Modelling Interactions and Behaviour © Lethbridge/Laganière 2005
21
Chapter 8: Modelling Interactions and Behaviour
© Lethbridge/Laganière 2005
22
Example: Online Chess
24
ExampleOnline Chess
25
ESE — Modeling Behaviour
Example: Phone ESE — Modeling Behaviour © Oscar Nierstrasz
26
Chapter 5: Modelling with classes
Outline State diagrams Modelling states and transitions Modelling activities and actions Examples Chapter 5: Modelling with classes © Lethbridge/Laganière 2012
27
Chapter 5: Modelling with classes
Readings and Videos Very Important R8: Chapter 8 (Modeling interactions and behavior) of OOSE, 2nd ed by Timothy Lethbridge Read section 8.2 from page 291 to page 301 Appendix A: Summary of UML Syntax – page 471 and 472 agram.htm Chapter 5: Modelling with classes © Lethbridge/Laganière 2012
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.