1 / 6

Strategy Design Pattern

Strategy Design Pattern. 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 .

Télécharger la présentation

Strategy Design Pattern

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Strategy Design Pattern B.Ramamurthy B.Ramamurthy

  2. 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. B.Ramamurthy

  3. Strategy Design B.Ramamurthy

  4. 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. B.Ramamurthy

  5. Mr.X and Strategy Design Pattern B.Ramamurthy

  6. Layout Example B.Ramamurthy

More Related