Intent - Allows you to use different rules or
algorithms depending on the context in which they occur. Uses the
process of Generalizing the solution, so that a single
solution solves a host of similar problems.
Problem -
Many related classes differ only in their
behavior.
You need different variants of an algorithm
You need to hide the algorithm specific data
structures from the client
You have a lot of switch or if -
then -else statements in your code to define
different behaviors in your class
Solution - Separates the algorithm from the
implementation and allows selection of the algorithm based
on context
Participants and Collaborators
Context
Strategy
ConcreteStrategy
Consequences
The Strategy pattern defines a family of
algorithms