Talk:Builder pattern: Difference between revisions

Content deleted Content added
Normana400 (talk | contribs)
Normana400 (talk | contribs)
Line 173:
:Using setters is not a replacement, because setters can cause the object to have an unstable and incomplete form. Builder pattern guarantees that the only object that is modified is the intermediatate object used while creating the final product. When the intermediate object is used up it is discarded. Builder pattern also allows flexible object construction. Suppose you have an object that might need many parameters. <span style="font-size: smaller;" class="autosigned">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/130.243.188.76|130.243.188.76]] ([[User talk:130.243.188.76|talk]]) 22:50, 13 December 2013 (UTC)</span><!-- Template:Unsigned IP --> <!--Autosigned by SineBot-->
 
=== page confusingly mixes two different unrelated builder patterns in its examples and explanations===
The java example is not the "GOF builder pattern". It's actually the "java builder pattern" (which is really a just a "fluent interface"). The GOF builder and the "java builder" are significantly different unrelated patterns. The java builder pattern is a wrapper for collecting settings used to eventually construct an object when you've collected enough. ie: new CarBuilder().wheels(4).paint("blue").type("sedan").interior("leather").makeItSo(); You can use it to with a protected constructor so that all entities that want to build an object have to use the builder to do it. You can also use this java builder pattern in scala to build immutable objects. So that is the java builder pattern. There's no director class for this type of builder. When the page is talking about the builder pattern being a wrapper around a constructor, its talking about the "java / fluent interface" pattern.