SE450
:
Strategy Pattern
[38/72]
Context
A class can benefit from different variants for an algorithm
Clients sometimes want to replace standard algorithms with custom versions
Solution
Define an interface type that is an abstraction for the algorithm
Actual strategy classes realize this interface type.
Clients can supply strategy objects
Whenever the algorithm needs to be executed, the context class calls the appropriate methods of the strategy object