Content deleted Content added
Normana400 (talk | contribs) |
Normana400 (talk | contribs) |
||
Line 174:
== 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. And it does it in an easy to read / write "sentence structure" 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.
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 using encapsulated builders (builders that no nothing about each other). And it uses a director to coordinate/orchestrate the work allocated to each builder to make the final compound object. So in the car example, you'd have builders that resemble steps in the car assembly with the director representing the "conveyor belt".
|