The State Pattern in Python - I Like How This Turned Out

ArjanCodes ยท Beginner ยท๐Ÿ“ ML Fundamentals ยท12h ago
๐Ÿงฑ Build software that lasts. Join the Software Design Mastery waiting list โ†’ https://arjan.codes/mastery. The classic State design pattern is often implemented with many small classes and heavy inheritance. In this video, I show a different approach. I start with the traditional object-oriented version and then refactor it into a generic, data-driven state machine using Python features like decorators, enums, and generics. The result is a clean, reusable engine where transitions are explicit and easy to understand. ๐Ÿ”ฅ GitHub Repository: https://git.arjan.codes/2026/state. ๐ŸŽ“ ArjanCodes Coโ€ฆ
Watch on YouTube โ†— (saves to browser)

Chapters (10)

Intro
3:24 Why This Matters
4:11 Step 1 โ€” The Traditional Class-Based State Pattern
4:57 Step 2 โ€” Realization: This Is Just a Lookup Table
5:21 Step 3 โ€” Extracting a Generic StateMachine
17:35 Step 4 โ€” Making Transitions Declarative with a Decorator
20:37 Step 5 โ€” Supporting Multiple From States
24:05 The Payment Class Becomes Boring (In a Good Way)
25:30 When To Use This vs Classic OO
25:54 Final Thoughts
Embeddings vs Latent Space Explained Simply
Next Up
Embeddings vs Latent Space Explained Simply
What's AI by Louis-Franรงois Bouchard