Strategy Design Pattern B.Ramamurthy 2/28/2019 B.Ramamurthy
Strategy Often there are alternative ways or strategies to achieve a goal. These strategies are usually realized using algorithms. Only one of them may be used depending on the context. The algorithms representing the strategies can be encapsulated each in a class. Strategy pattern itself represents a collection of these alternative ways in a hierarchy of classes, each class representing an alternative. 2/28/2019 B.Ramamurthy
Strategy Design 2/28/2019 B.Ramamurthy
Examples Different layouts for graphical components (JFrame, JPanel, JApplet) Checkout counter software has TaxCalculator class. Depending on the place (context) the tax computation differs. Mr.X’s strategies in the ScotlandYard game. 2/28/2019 B.Ramamurthy
Mr.X and Strategy Design Pattern 2/28/2019 B.Ramamurthy
Layout Example 2/28/2019 B.Ramamurthy