States, events, and returns
A state diagram shows the states of one thing, the events that move it, and where it starts and ends. Guards and arrows that loop back to an earlier state belong on this picture.
A flowchart is the neighbor for a procedure with decisions a person follows. A sequence diagram is the neighbor for messages between participants. Stay here when the boxes are conditions, not tasks.
State diagram or flowchart
Use a state diagram for a lifecycle such as an order or a connection. Use a flowchart for steps such as approve, pack, and ship when those are work, not states. A loop back to paid is a state story.
Fix guards and loops
1. Mark start and end
Say which state is initial and which states are final. If the draft has neither, add them before anything else.
2. Put the guard on the right arrow
A condition such as paid only when stock remains must sit on the transition. Move it if the draft attached it to the state name.
3. Draw real loops back
If a failure returns to an earlier state, the arrow must point there. A new box with the same name is a mistake to merge.
How to phrase the prompt
Name the object, list its states, and describe each transition as from, event, guard, and to. Mention loops back in a sentence of their own. Do not list assignees or calendar dates.
State draft questions
- Can one state have two exits?
- Yes. Give each exit its event or guard. If you cannot name the difference, you do not have two transitions yet.
- The draft looks like a flowchart of tasks. What now?
- Rename boxes to conditions, such as unpaid, and put verbs on the arrows. If the boxes must stay as work steps, switch to a flowchart.
- How do I show a return to the start?
- Say which event sends the object back, and to which state. Check that the draft arrow loops back instead of ending.