- Definition: SMD describes the behavior of a single class object. It identifies
n What states the object can be inn What messages make the object change its staten Which objects require status checkingn Which business rules determine valid status- State: a condition that occurs during the life of an object when it satisfies some criterion, performs an action or waits for an event
- Conditions are “semi-permanent” -- becuase it moves
- A new state can be triggered by
- External event
- Internal change (data or time)
- Transition: movement of an object from one state to another
- When the object is in a different state, there is a business rule that is associated with this state change, and it is important to know what object is associated what business rule at what state.
SMD & OID
- Each statechart details the object states in the sequence diagram.
Naming Conventions
- A simple condition -- e.g. "on" or "off"
- Active names consisting of “…ing” or verb phrases -- e.g. "waiting" or "shipped"
Should not be nouns- Object may automatically perform an action when entering or leaving a state
Components
- Pseudostate: Starting point noted by black dot
- Destination State: State which an object moves after the completion of a transition
- Origin State: Original state of an object from which the transition occurs
- Transition Label (Message):
Transition-name (parameters, …) [guard-condition] / action expression
- Guard Condition – qualifier or test on the transition, true/false condition that must be satisfied before the transition can fire
- Action Expression – indicates some process that must occur before the transition is completed and the object arrives in the destination state
- If either the transition-name or guard-condition is empty it evaluates to true
Example
- Starting with the "off" state
- On Button is pushed AND the bin is not empty AND safety cover is closed
- Run self-test()
- If the status returned is true, go to "on" state
How to make a SMD?
Concurrent state
i.e. More than one state at a time
Example
n
Person object has
marital
status
&
citizen
status
Internal state
-
Entry: action executed when entering the state
-
Do: action executed while in the state
-
Exit: action executed before leaving the state
Concurrent Path
- Things that can happen in parallel.
- State Machine Diagram represents concurrent behavior with multiple paths called threads
- There are 2 different graphical representations of conccurent paths
- Upper: Swimlane
- Lower: Synchronization Pseudostate, where vertical bars indicate where concurrent behavior begins or ends (called pseudostates)
Example
![](https://i-blog.csdnimg.cn/blog_migrate/df89694f01e135f0c56ce7c9f7443f90.png)
Class Exercise
- Initially, the pone is turned off
- When the phone is switched on
- Plugged in and