Behavioral patterns
Strategy
Interchangeable algorithms in separate classes, picked at runtime.
Article
Strategy: interchangeable algorithms instead of an if-else ladder
The Strategy pattern through courier assignment in a pierogi place: a family of interchangeable algorithms behind one interface, swapped at runtime. Code in C#, TypeScript, Java, Go and Python.
Related articles
- Bridge – two axes of change without a class explosion
Bridge separates the abstraction (what we do) from the implementation (how we do it), so both hierarchies can evolve independently. An example of notifications and delivery channels in C#,…
Challenges
- Discount strategy medium
- Design patterns – basics Quiz
Around the topic
- Strategia / Strategy article · web · Refactoring.Guru
- Strategy Pattern – Design Patterns (ep 1) video · youtube · Christopher Okhravi
- Design Patterns in Dynamic Languages | Code Walks 016 video · youtube · Christopher Okhravi
- Head First design patterns book · openlibrary · Eric Freeman, Elisabeth Freeman, Kathy Sierra, Bert Bates
- Design Patterns: Elements of Reusable Object-Oriented Software book · openlibrary · Erich Gamma, John Vlissides, Richard Helm, Ralph Johnson
- Strategy article · web · Refactoring.Guru