Strategy pattern in java

Hi Friends,

today i want to share strategy pattern, of course this is very well known and mostly used pattern. and their is lots of cases where we need to use strategic pattern.

#what is Strategy pattern?

The strategy pattern(also known as the policy pattern) is a software design pattern that enables an algorithm’s behavior to be selected at runtime. The strategy pattern. defines a family of algorithms, encapsulates each algorithm, and makes the algorithms interchangeable within that family. more

#When to use?

when we have multiple algorithm for a specific task and want to decides the actual implementation to be used at runtime

#Example

Suppose there is one software startup company and they have limited resource to done their work but all resource have multi-talent to do multiple roles,  like four resources (EmployeeA, EmployeeB, EmployeeC, EmployeeD) each one can able to done coding, testing,content writing etc. and any work can assign to anyone . its depend on availability.

Screen Shot 2015-10-22 at 3.10.43 AM

you can find example on Github link

Thanks

 

Advertisements