Flowchart Vs State Diagram Link to heading
[!summary]
- Flowchart -> nodes are actions or decisions -> edges are flow of control (i.e.: “what happens next?”)
- State Diagram -> nodes are state -> edges are something that triggers state change.
Visually both of these are very similar, but they are used to represent systems in different ways.
Both are complementary: an action/decision in a flowchart could trigger events that cause state change. They are not necessarily one-to-one however: an action may cause several state changes with no indication in the flowchart
Node | Edge | |
---|---|---|
Flowchart | Actions or decisions | Flow of control |
State Diagram | System state | Actions that trigger state change |
---
title: Order - Flowchart
---
flowchart TB
ro(System receives order from user) --> fi(Find items in inventory)
fi --> si(Send items to shippment)
si --> aais(Check: Are all items sent?)
aais -- Yes --> in(Prepare and send invoice)
aais -- No --> fi
---
title: Order - State Diagram
---
stateDiagram-v2
r1: received
p1: preparing
s1: shipping
d1: delivered
[*] --> r1
r1 --> p1
p1 --> s1
s1 --> d1
d1 --> [*]
Both can tell the same story, but from different angles and with different details.