What is the intent of the Strategy Pattern ?
Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
What is the motivation of the Strategy Pattern ?
Many algorithms exist for breaking a stream of text into lines. Hard-wiring all such algorithms into the classes that require them isn’t desirable for several reasons:
We can avoid these problems by defining classes that encapsulate different line-breaking algorithms. An algorithm that’s encapsulated in this way is called a strategy.
What is the applicability of the Strategy Pattern ?
Use the Strategy pattern when
What are the participants of the Strategy Pattern structure ?
What is the role of the concrete strategies participants in the Strategy pattern structure ?
implements the algorithm using the Strategy interface.
What is the role of the strategy interface participant in the Strategy pattern structure ?
declares an interface common to all supported algorithms. Context uses this interface to call the algorithm defined by a ConcreteStrategy.
What is the role of the Context participant in the Strategy pattern structure
– maintains a reference to a Strategy object.
– may define an interface that lets Strategy access its data.
Describe the collaborations between the Strategy pattern participants ?
What are the benefits and drawbacks of the Strategy Pattern ?
What are the implementation challenges/issues of the implementation of the strategy pattern ?