Strategy pattern is used when we have multiple algorithm for a specific task and client decides the actual implementation to be used at runtime.
We defines multiple algorithms/classes and let client application pass the algorithm to be used as a parameter.
Example: Collections.sort() method that takes Comparator parameter. The list can be sorted in different ways using different implementations of Comparator interfaces.
Elements Strategy Pattern
Common Interface that implemented by to all supported algorithms (ConcreteStrategy).
ConcreteStrategy (QuickSort, ShellSort, MergeSort)
Implements the algorithm using the Strategy interface.
Maintains a reference to a Strategy object and logic to use Strategy object.