Talk:Builder pattern: Difference between revisions

Content deleted Content added
Normana400 (talk | contribs)
Critics: adding commentary that this page is co-mingling 2 unrelated patterns
Line 169:
== Critics ==
 
I'm missing the critics section, because the builder pattern is just deeply bad Java, creating a unecessaryunnecessary complex code and nothing else. Probably those people programming builders didn't understand what a constructor is and what a setter and a getter is. Too bad. It should be forbidden. Furthermore, builder are not real object oriented code, so they also need callback patterns, like in the old days with Fortran and C. But callbacks should nowadays be used only for assymetricasymmetric processes, and not for models at all. That's probably why we need (only) one new programming language in the future, prohibittingprohibiting all those bad implementation patterns. Or, at least a Java compiler who prohibits it. [[Special:Contributions/178.197.234.31|178.197.234.31]] ([[User talk:178.197.234.31|talk]]) 13:36, 6 June 2013 (UTC)
:If somebody comes and says "how am I supposed to do fast parsing without a builder?", you are right in using a builder for loops, like a StringBuilder. But this is a very special case and is only used for parsing Strings. However, for normal objects you should use Externalizable to parse them (newer use Serialisation because it's only 30% Externalizable's speed). So please don't misunderstand me: Builder are okey in a very limited case of String parsing...but then we create the StringBuilder, use it instantly in a loop and afterwards we forget about it. But to use the builder pattern for more than String parsing is just dumb. [[Special:Contributions/178.197.236.254|178.197.236.254]] ([[User talk:178.197.236.254|talk]]) 14:36, 6 June 2013 (UTC)
: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 the "java builder pattern". They 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. Theres 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 this pattern.
 
The GOF builder pattern is not like this at all. Whereas the java builder pattern is more about convenient sentence like construction, the GOF builder is more about building a complex/compound object with encapsulated builders that no nothing about each other and one director that can provide them with what each builder needs to get started and coordinate/orchestrate their work to eventually make the compound object. So in the car example, you'd have builders that more resemble steps in the car assembly with the director representing the "conveyor belt(s) / build process".
 
with that in mind, I think this page should be split into 2 sections, one for the GOF pattern and one for the Java build pattern
<ref>http://stackoverflow.com/questions/26256604/is-the-java-builder-pattern-bloch-really-related-to-the-gof-builder</ref>
[[User:Normana400|Normana400]] ([[User talk:Normana400|talk]]) 18:47, 17 March 2017 (UTC)
 
== Wrong example ==