State Machines
summary
Introduces using the automat library and its MethodicalMachine class to replace ad hoc if‑checks with explicit states and transitions, demonstrated by a three-state kettle (empty → full‑cold → full‑hot) with inputs fill/boil/pour that raise exceptions on invalid transitions. Outputs run only after a transition is validated, can accept args and return results (currently as a list), and the library supports serialization and auto‑diagramming. Limitations include awkward multi‑return handling and no built‑in hierarchical states; the demo works as shown.
AI-written summary · about
chapters (13)
- 0:00Intro
- 1:26What is a state machine?
- 2:22Why methodical state machines?
- 7:04The Code - Manual class Kettle(object)
- 8:48The Code - Boilerplate
- 9:20The Code - States
- 10:03The Code - Inputs
- 10:42The Code - Transitions
- 12:04Invalid Usage
- 13:32Taking Arguments - Outputs
- 15:45Returning Results - Outputs
- 17:18Outputs - Results
- 18:29Automat: Advanced Features
related talks
36mState Machine in Elixir with Machinery
28mState machines for frontend state management
46mState Machines (The Good, The Bad and The Ugly)
24mLeveraging the Power of State Machines in Swift
38mInto the Visual World of State Machines
37mState Machine: What It Is and Why
46mFinite-state machines? Your compiler wants in!
28msetState Machine
