Thursday 16 February 2012

Builder Vs Factory

Builder - Create another object of specific type over several steps.
Builder - Holds the needed state for the target iteam at each step.
Example: When you ask for Car it will give Hond with 4 Cylnder or Honda with 6 cylnder engine or Maruthi.
Example: Make a loan object, There are several loans(education, personal, car, house) and intrest rates are different, So the final object is created with Step by step process.


Factory - Create another object of specify type in one step.
Example: When you ask for Cat it will give Honda or Maruthi.
Example: When there is a super class and 'N' number of subclass, Depends on the parameter the object will create and return.

No comments:

Post a Comment