State machine: the order lifecycle
Replace status booleans with explicit states and one table of allowed transitions.
Level Intermediate
What you will see
- Four booleans, sixteen states
- Make impossible states unrepresentable
- Each state carries its own data
- One table for every move
- Guards: allowed by the table, decided at run time
- When a flag is just a flag
Before / after
Base: naive-crud-tsView the diff