Strategy

Define a family of algorithms, encapsulate each one, and make them interchangeable.
Strategy lets the algorithms vary independently from clients that use it.
Applicability
- Need many related classes that differ only in their behavior
- Need different variants of an algorithm
- Need to hide algorithm data from the clients
- A class defines many behaviors and these appear as multiple conditional statements in its operations.
(See also State.)
Consequences
- Families of related algorithms
- An alternative to subclassing the Context
- Strategies eliminate conditional statements
- Allow choice of implementation
- Clients must be aware of different strategies
- Communication overhead between Strategy and Context may be high
- Increased number of objects