Friday, August 12, 2016

Builder Design Pattern

Builder pattern builds a complex object by using a step by step approach. Builder interface defines the steps to build the final object


Builder 
  • This is an interface which is used to define all the steps to create a product 
  • E.g. IVehicleBuilder
ConcreteBuilder
  •  This is a class which implements the Builder interface to create complex product. 
  • E.g. HeroBuilder & HondaBuilder
Product
  • This is a class which defines the parts of the complex object which are to be generated by the builder interface.
  • E.g. Vehicle
Director
  • This is a class which is used to construct an object using the Builder interface.
  • E.g. Vehicle Creator

When to use it?
  • Need to create an object in several steps (a step by step approach).
  • The creation of objects should be independent from the way the object's parts are assembled.
  • Runtime control over the creation process is required.
http://www.dotnet-tricks.com/Tutorial/designpatterns/6aMR040613-Builder-Design-Pattern---C

No comments:

Post a Comment