03Behavior models
A system with defined states
A state machine describes named states and rules for moving between them. The current situation helps determine what happens next.
Name the situation
A state represents a meaningful mode, such as waiting or processing. A transition describes a permitted change from one state to another. An event may trigger that change, and a condition may determine whether the transition is allowed.
A description needs a starting state and rules for events without a permitted transition: ignore them, record an error or enter recovery.
A hypothetical document workflow
Imagine a document with three states: draft, in review and final. It starts in draft. Submitting a draft moves it into review. Requesting changes returns it to draft. Accepting it moves it to final. The same request can therefore have a different meaning depending on the current state.
This illustrative workflow makes allowed changes visible. It is not a company procedure.
| Current state | Event | Next state |
|---|---|---|
| Draft | Submit | In review |
| In review | Request changes | Draft |
| In review | Accept | Final |
A model has a scope
Diagrams help discussion; transition tables can expose missing cases. Neither automatically resolves simultaneous events, timing requirements or failures during transitions. These need explicit rules.
Too few states conceal differences; too many obscure the model. Choose states that change decisions, rather than naming every implementation step.
Further reading: MathWorks: Model a Finite State Machine.