Strategy Design Pattern by example
This post explains Strategy design pattern using an example. When to Use ? – Its an alternative to Template Design Pattern. Use this pattern when template methods implementation as well as steps in which they need to execute are dynamic. Its like no of steps in algorithm vary or the class that implements the steps needs as independent inheritance hierarchy . How to use ? – Implement an interface defining the individual steps. Define a class that implements this interface ( individual steps) , this class is not forced to inherit from an abstract template super class. Main algorithm implementation class uses this interface implementation for each of algorithm steps execution An example – Same example as Template Method Design pattern is being used, Process order. Interface - package strategypattern; import java.util.List; import templatemethod.Order; public interface ProcessOrderHelper { public boolean validateCustomer(String custName...