not sure if 'm correct here.
Builder pattern are usually us when you need to create an object using multiple step. like Creating a car, you create th eengine, tire, tec..and put together the car. the step to creating the car can be different each time.
public Car createCamry(){
Engine e = new TurboEngine();
Tire tire = new Tire();
Camry c = new Camry();
c.addEnhine(e);
// etc
return Car
}
In Factory, you generally create the object in one step..
public Car createCamry(){
return new Camry();
}
You are right Both of these patterns are creational design patterns Purpose of these two patterns is very different as Abstract Factory Patterns (which is commonly known as Factory pattern ) is used to create a object in a scenario when you have a product & there is a possibility of many vandors providing implementation for it. So it is good to come up with a abastract factory which provides create method for the product. Each vendor can implement you abstract factory & provide a concrete implementation which will return a product of Vendor implementation.
Builder patter is used in case you have a very complex object creation process involved & you realy want to abstract the client from doing all those complex steps. In such situation you create a builder class which takes care of all complex steps & client just needs to use this builder class to create your complex object.
Hope it clarifies your doubts.
> > The shortest answer would be "Builder separates
> the
> > construction of complex objects from their
> > representation."
>
> http://www.programmersheaven.com/articles/faisal/patte
> rn.htm
Yuck, what was that, .net?
Try a java one: http://www.fluffycat.com/java-design-patterns/