Strategy design pattern
The Strategy design pattern encapsulates interchangeable algorithms or behaviors behind a common interface so they can be selected independently of the code that uses them.
Software Design for Python Programmers
A strategy is an encapsulated algorithm that provides interchangeable behavior for a client.
- How it is used
- Manages interchangeable algorithm families when runtime decisions and independently changeable behavior are required.
- How deep it goes
- Works from inheritance problems through interfaces, composition, delegation, setters, concrete strategies, and runtime replacement.
- Examples
- Demonstrates sports teams using player-recruitment and venue strategies, including replacing volleyball's open field with a stadium.
- What you can do after
- Build it from scratch by separating algorithm families behind interfaces and selecting or replacing implementations at runtime.
Read how Software Design for Python Programmers explains strategy design pattern →
Object-Oriented Software Design in C++
The Strategy Design Pattern is a behavioral design pattern that encapsulates interchangeable algorithms behind a common interface so one can be selected independently of the client that uses it.
- How it is used
- Manages interchangeable algorithm families when an application must choose behavior at run time.
- How deep it goes
- Explains interfaces, composition, delegation, replacement, and trade-offs, but stops short of a library-based implementation.
- Examples
- Uses baseball, football, and volleyball strategies for recruiting players and reserving stadiums or open fields.
- What you can do after
- Build it from scratch by defining strategy interfaces, implementing algorithm variants, aggregating them in a client, and switching them at run time.
Read how Object-Oriented Software Design in C++ explains strategy design pattern →
Related concepts
- design patternkind of · A design pattern is a reusable, general solution structure for a recurring software design problem in a particular context.
- abstract factory design patterncontrasts with · The Abstract Factory is a creational design pattern that provides an interface for creating families of related objects without specifying their concrete classes.
- machine learninguses · Machine learning is a field of computational methods in which systems learn patterns or relationships from data to make predictions, decisions, or other outputs.
- compositionuses · Composition is a technique for combining simpler functions, components, or operations into a larger structure or behavior.
- template method design patterncontrasts with · The Template Method design pattern defines an algorithm's fixed sequence in a superclass while allowing subclasses to implement or customize selected steps.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

