The state machine diagram
An object's behaviour over time: states, initial and final states, transitions triggered by an event, guards, effects, and entry and exit activities.
- 23 cards
- 3 topics
- Free
The outline, topic by topic
Each topic is weighted the way the exam weighs it.
- Concepts
- Questions
- Sort and link
A few cards from the deck
State machine diagram: what is it?
Show the answer
A UML diagram that describes the successive situations an object may be in and the events that move it from one to the other.
It is used for an object whose reaction to an event depends on its past: an order, an account, a cash machine.
An order has these transitions: Pending -pay-> Paid, Pending -cancel-> Cancelled, Paid -ship-> Shipped, Shipped -deliver-> Delivered. No others. Which state is it in after pay, cancel, ship?
- Shipped
- Cancelled
- Paid
- Pending
Show the answer
Shipped
payleads to Paid. Nocanceltransition leaves Paid: the event is ignored and the state does not change.shipthen leads to Shipped.A transition label reads: … […] / ….
Show the answer
A transition label reads: event [guard] / effect.
The guard and the effect are optional, and the order is always the same: what triggers, the condition, then what is performed.
State: what is it?
Show the answer
A lasting situation of an object during which some reactions are possible and others are not, such as Pending or Paid.
A state is named with an adjective or a participle (Paid, Locked): what is true of the object for some time, not an action.
A Pending order has the transition
pay [amount received ≥ price] / send the receipt. The customer pays €30 for a price of €50. What happens?- It moves to Paid, but the receipt is not sent
- It stays Pending, with no receipt
- The receipt is sent, then the transition is cancelled
- It moves to Paid with a receipt showing the missing amount
Show the answer
It stays Pending, with no receipt
The guard is evaluated before the transition: false, it blocks it, so the effect is not performed. To handle this case (partial payment), another transition with the opposite guard would have to be drawn.