Behavioral patterns
State
An object's behaviour changes with its internal state, replacing sprawling conditionals.
Article
State: an object that changes behaviour with its life stage
The State pattern through an order in a pierogi place: New, Paid, InKitchen, Delivered and Cancelled as separate objects that guard the allowed transitions themselves. A state machine without an if-else ladder, code in five languages.
Related articles
- Circuit breaker: turning a slow failure into a fast one
The Circuit Breaker pattern from the ground up: closed, open and half-open states, thresholds and windows, filtering business errors, working with timeouts, retries and bulkheads. Configuration in…
Challenges
Around the topic
- State · Design Patterns Revisited · Game Programming Patterns article · web · Robert Nystrom
- Stan / State article · web · Refactoring.Guru
- Mauro Servienti - Talk Session: Welcome to the (State) Machine video · youtube · Explore DDD
- Head First design patterns book · openlibrary · Eric Freeman, Elisabeth Freeman, Kathy Sierra, Bert Bates
- State article · web · Refactoring.Guru
- Episode 16. Let’s talk about the STATE of things. A brief intro to the State pattern podcast · apple-podcasts · Java Pub House