This post originated from an RSS feed registered with Java Buzz
by instanceof java.
Original Post: Builder design pattern in java with example program
Feed Title: Instance Of Java
Feed URL: http://feeds.feedburner.com/blogspot/TXghwE
Feed Description: Instance of Java. A place where you can learn java in simple way each and every topic covered with many points and sample programs.
Design patterns are solutions to software design problems.
Design patterns classified into three types.
Creational, Structural and behavioral design patterns.
Creational patterns helps us to create objects in a manner suitable to the given situation.
Builder design pattern is one of the creational design pattern in java.
Builder design pattern helps us to create complex class object.
Builder design pattern helps us to separate the construction process of a complex object from its representation so that same object construction process can be created in different representations.
Means it will separate complex construction into two parts initialization of class instance and return class instance.
When a class having more number of fields and constructor of that class take care of assigning initial values.
And when we want to create object of the class we need to pass all parameters and should be in same order which constructor is accepting.
Builder design pattern helps us to create same class object by passing required number of fields by using separate builder class object.
Builder design pattern is useful when object creation is very complex.