What do you mean by Factory pattern? This could refer to either the Factory Method pattern or the Abstract Factory pattern. The Builder pattern differs from Factory Method in that the instance is constructed by another object in the Builder pattern, whereas with a Factory, the class creates it's own instances
Thanks georgemc for your instant reply.
Actually I am referring Java Design Patterns by James W. Cooper.
according to that book, there are three factory patterns, simple factory pattern, factory method pattern and abstract factory pattern.
I am getting confused in simple factory pattern and builder pattern.
I explain that book's terminolory, and the point where I am getting confused.
Simple Factory Pattern:
There is a superclass X, and it is having two subclasses AX and BX.
Then there is a class XFactory, with a function getX(arg);
Now getX returns AX or BX according to the arg passed.
Now for Builder pattern the book specifies the similar type of structure, and just made two statements:
1. The XFactory is called Director and AX and BX returned from that are called Builder.
2. Builder pattern is little more than a Factory pattern because the objects returned are not simple descendents of a base display object, but rather totally different user interfaces made up of different combinations of display objects.
That would mean we are visualizing the same pattern with two different perspectives.
I am totally lost. Please help me out.