State machine: the order lifecycle

Replace status booleans with explicit states and one table of allowed transitions.

Level Intermediate

What you will see

  1. Four booleans, sixteen states
  2. Make impossible states unrepresentable
  3. Each state carries its own data
  4. One table for every move
  5. Guards: allowed by the table, decided at run time
  6. When a flag is just a flag

Before / after

Base: naive-crud-tsView the diff

Exercises