Talk:Builder pattern: Difference between revisions

Content deleted Content added
Line 178:
 
[[User:Javierieh|Javierieh]] ([[User talk:Javierieh|talk]]) 02:51, 11 November 2014 (UTC)
 
== "Different representations": What? ==
 
The preface to the article suggests that the Builder Pattern is basically a solution for creating an object in a programming language where named arguments are not supported, but the member variables have default values that can be overridden, and if they are to be overridden, it should be done upon instantiation. So you create an auxilliary class that collects the arguments to a constructor and then creates the object.
 
So, in a programming language that does support named arguments, the pattern
disappears:
 
<source lang="python">
class Pizza:
def __init__(self,dough='Hand Tossed', sauce='Marinara', topping='Cheese'):
self.dough=dough
self.sauce=sauce
self.topping=topping
 
# Use the standard dough
p = Pizza(sauce='Garlic Butter', topping='Pepperoni')
</source>
 
...But then, the "Definition" section of the article says this:
 
<blockquote>
The intent of the Builder design pattern is to separate the construction of a complex object from its representation. By doing so the same construction process can create different representations.
</blockquote>
 
....which seems to have nothing to do with the purpose of the pattern. Now it sounds like they're talking about being able to create a big endian representation of an integer or a string representation of the same integer with the same constructor class.
 
None of the code examples show a class that creates objects that offer different representations of the same value. All of the examples show classes that can selectively fill in member variables of the object that is about to be created. An object which only has one representation.
 
What the point would be of doing this is a separate question. [[Special:Contributions/184.57.129.13|184.57.129.13]] ([[User talk:184.57.129.13|talk]]) 12:20, 8 March 2015 (UTC)