Strategy
Collaborations
-
Strategy and Context interact to implement the chosen algorithm. A
context may pass all data required by the algorithm to the strategy
when the algorithm is called. Alternatively, the context can pass
itself as an argument to Strategy operations. That lets the strategy
call back on the context as required.
-
A context forwards requests from its clients to its strategy. Clients
usually create and pass a ConcreteStrategy object to the context;
thereafter, clients interact with the context exclusively. There is
often a family of ConcreteStrategy classes for a client to choose
from.