Strategy Pattern
A Strategy Pattern says that "defines a family of functionality, encapsulate
each one, and make them interchangeable".
The Strategy Pattern is also known as Policy.
Benefits:
o It provides a substitute to subclassing.
o It defines each behavior within its own class, eliminating the need
for conditional statements.
o It makes it easier to extend and incorporate new behavior without
changing the application.
Usage:
o When the multiple classes differ only in their behaviors.e.g. Servlet
API.
o It is used when you need different variations of an algorithm.
Strategy Pattern in (Core Java API's) or JSE 7 API's:
Strategy Pattern in (Advance Java API's) or JEE 7 API's:
UML for Strategy Pattern: