A State Transition Table for a Small Workflow

Model a workflow by writing the next state for each allowed combination of current state and input event.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Track retained state
  2. Run a short sequence
  3. Trace the current state and the attempted event
  4. Check repeated events and changes made around them

Track retained state

An order in draft can receive a submit event and become submitted. A submitted order receiving a confirm event becomes confirmed. Write rejected event-state combinations explicitly, including repeat submissions. A decision table helps you check the possible rows.

Run a short sequence

Starting in draft, submit followed by confirm succeeds. Confirm followed by submit first attempts an invalid action. Record both the reported outcome and the retained state after rejection. A trace of program state reveals when an implementation accidentally updates before validating the event.[1][2]

Trace the current state and the attempted event

A simple request can begin in draft. Submitting moves it to pending review. Approving while pending moves it to published. In the table, the key is the pair of current state and event. Approving from draft can preserve draft and report that submission is needed. Put both the resulting state and the reported outcome in each row. Then try approve, submit, and approve from a fresh draft. The first attempt fails, and the following two transition coherently. See input, state, and output.

Check repeated events and changes made around them

A second submit on a pending request can return the existing state without adding another review request. If the interface instead rejects duplicates, record that response while keeping the same persisted state. If notifications or audit records are part of the workflow, include their expected behavior separately from the main transition. Idempotent transitions explains when a repeat is meant to leave the system in its already-established state.

Build tests for one ordinary path and one sequence entering an unrecognized or invalid event. Verify the state after every step, not merely the last row reached.

References

  1. Python Software Foundation, Python Tutorial: Control Flow ↩
  2. Python Software Foundation, Python Language Reference: Expressions ↩