Skip to content

State Machine Diagram Modeling Mistakes

A state machine diagram shows the states an object can be in and the transitions between them (see State Machine Diagram and State Machine Transition). Most mistakes fall into a few groups.

Initial and final markers

  • An initial pseudostate is the starting marker. It is the source of a single transition to the default state. Do not draw several outgoing arrows from it.
  • A final state means the enclosing region is completed. Use it when the behavior is meant to end.

Completion transitions

  • A completion transition has no explicit trigger. An implicit completion event fires it.
  • Completion events are dispatched ahead of other pooled events. An unguarded completion loop could therefore starve other events.
  • If one state has several completion transitions, give them mutually exclusive guards. Otherwise the choice is ambiguous.

Guards and the else branch

  • A guard is a condition on a transition. Guards leaving one source should not overlap.
  • The else transition is enabled only when all other guards from the same source are false. It covers the remaining cases.

Entry and exit points

  • Entry and exit point pseudostates belong to a state machine or a composite state. Do not place them on a simple state.
  • A composite state contains other states (see Composite State).

Transition kinds

  • UML defines three transition kinds: external, internal and local. Choose the kind on purpose.

A “Payment” object leaves the “Checking” state through two completion transitions. One has the guard [amount <= limit] and goes to “Approved”. The other has the guard [amount >= limit] and goes to “Declined”. At exactly the limit, both guards are true, so the choice is ambiguous. The fix is to make the guards disjoint: keep [amount <= limit] and mark the second transition [else]. The else transition then fires only when the first guard is false.

Disjoint guards with an else branch leave one clear choice.

Diagram source
@startuml
[*] --> Checking
Checking --> Approved : [amount <= limit]
Checking --> Declined : [else]
Approved --> [*]
Declined --> [*]
@enduml
  • Each region has an initial pseudostate with a single transition to the default state.
  • Completion transitions leaving the same state have mutually exclusive guards.
  • Where an else transition is used, it is the fallback for a source whose other guards can all be false.
  • Entry and exit points appear only on a state machine or a composite state.
  • A final state is used where a region is meant to complete.