Builder pattern
Intent: Separate the construction of a complex object from its representation so that the same construction process can create different representations.
See also: ClassFactory, AdapterPattern
http://rampages.onramp.net/~huston/dp/builder.html
http://wiki.cs.uiuc.edu/PatternStories/BuilderPattern
Given that a CompositePattern is often what BuilderPattern builds, is there a corresponding DestroyerPattern that can nicely remove pieces of a CompositePattern?
How is this different from a factory pattern?
The BuilderPattern is similar to a FactoryPattern, but creates a complex object using a number of steps. If the product is a CompositePattern you may need to remove some of the pieces later. If I understand correctly, you are proposing to just create an entirely new composite from the factory. What I am wondering is whether patterns have been explored that reverse some of the steps from a BuilderPattern. In other words, modifying the composite built by a builder by performing the reverse of some of the steps used to build it. An example would be a tree built from parsed data. Later you may want to parse an update that removes a few nodes and adds a few nodes to the original. Much of the logic from the original builder applies, but some of the operations destroy instead of build.
Sounds like we should have more of a LabourerPattern... "Build me a 10 story tower" "Take off the top 3 stories" etc... CareyUnderwood
Hmmm. Interesting. Maybe instead of just having BuildPartA, BuildPartB methods, you also have DestroyPartA and DestroyPartB methods?
Essentially I find no difference between a Abstract Factory Pattern and Builder .Assume there is no family of products but just a list of independent products.Also let it be so,that instead of the client using the Factory to create objects, we have one more class (director) which encapsulates all that the client should do..We have a builder pattern here.It's no pattern.. just a wrapping up together what a client should do..It's just a specialized case of Abstract factory pattern ..Praveen George
Abstract factory is the answer to what and the builder to how.
Does that mean builder can be the consumer of the products of an Abstract Factory ??
A Builder can be one of implementations of the AbstractFactory. Of course it can use other factories to build the parts of its product.
And Abstract factory in fact could be creating builders??
Yes :-) A MetaFactory
CategoryPattern | CategoryCreationalPatterns