Thursday, October 25, 2012

Strategy Pattern


A manufacturing company produces different products, and they sell it with help of distributors. Manufacturing company and distributor makes agreement like 10% rebate for 1000 products. Rebate claim by distributor can be send to company in the form of files (txt, excel1, excel2, excel3). And claim management system processes these files. 


txt         - process directly
excel1 - 4 columns template
excel2 - 8 columns template
excel3 - 9 columns template

Which GoF pattern is ideal in this scenario?

Solution: Strategy pattern

  • Strategy is a behavioral pattern
  • algorithms can be selected at runtime
  • defines a family of algorithms, encapsulates each one, make them interchangable

Reference: 
http://www.dofactory.com/Patterns/PatternStrategy.aspx
http://en.wikipedia.org/wiki/Strategy_pattern




No comments: