is already immutable and the builder is the one thas is not with the added methods
what are the "addX" methods for ? if immutability is the goal ?
this example fails to display the purpose of the builder pattern IMHO
for another idea of implementation:
new Burger(size, ingredients)
with size and ingredients being higher representation (Dict/Set/HashMap)for example:
size can be a set of "big, small, medium"
ingredients can be "pepperonni: true" or "cheese: new Cheese("gouda")"
We have to kill this trend to make code for making code and remember that code is a higher level of expressing a solution/process.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
that example is so OOP overkill that i don't know where to start
first:
instead of
1 constructor VS 1 constructor + 4 methods call, what's the gain ?
second:
you got 2 objects creations instead of 1
what's the gain ?
third: immutability
is already immutable and the builder is the one thas is not with the added methods
what are the "addX" methods for ? if immutability is the goal ?
this example fails to display the purpose of the builder pattern IMHO
for another idea of implementation:
with size and ingredients being higher representation (Dict/Set/HashMap)for example:
size can be a set of "big, small, medium"
ingredients can be "pepperonni: true" or "cheese: new Cheese("gouda")"
We have to kill this trend to make code for making code and remember that code is a higher level of expressing a solution/process.