Static Class Structure
Context
Strategy
interface to perform an algorithm
(strategy.algorithm())
strategy)
to a Strategy
object.
Strategy
Strategy1,Strategy2,…
Strategy interface.
Dynamic Object Collaboration
Context object
delegates performing an algorithm
to different Strategy objects.
Context is
configured
with a
Strategy1 object.
Context object
that calls algorithm() on
its installed
Strategy1 object.
Strategy1
performs the algorithm and returns the result to
Context.
Context
changes its strategy to Strategy2
(because of run-time conditions
such as reaching a threshold, for example).
Context
now calls algorithm() on
the
Strategy2 object,
which performs the algorithm and returns the result to
Context.
Context
might change the strategy
or pass the strategy
to the Context.