Define a family of algorithms, encapsulate each one, and make them interchangeable.
Strategy lets the algorithm vary independently from clients that use it.
there are many related classes that differ only on their behavior. Strategy provides means to configure a class with different behaviors.
you need different variants of an algorithm.
an algorithm uses properties that clients should not access.
a class defines many behaviors, which appear as multiple conditional statements in its operations.
A sorted list, with different sort algorithms.
The sort algorithm may be replaced at runtime.
Strategy defines an interface for a family of algorithms.
Each Concrete Strategy implements a different algorithm
The Context defines the current algorithm and provides property access to algorithms.
Hierarchies of Strategy classes define a family of algorithms or behaviors for contexts to reuse.
Provides an alternative to subclassing.
Eliminates the use of conditional statements
Provides different implementations of the same behavior.
A client must understand how Strategies differ before it can select the appropriate one.
Communication overhead between Strategy and Context.
Object proliferation.
The Strategy and Context interfaces must give a Concrete Strategy efficient access to any data it needs from a context, and vice versa.
In C++ templates can be used to configure a class with a strategy.
Design Patterns: Elements of Reusable Object-Oriented Software. Erich Gamma, Richard Helm,Ralph Johnson, and John Vlissides. Addison Wesley. October 1994.