>>109104118
> Yes, you do
No you don't
Why would you need a builder in a language that naturally supports incremental object creation and extension ?
You can just do
Prototype -> clone -> customized instance
Remember that object are not static entities like in class-based OOP, you create an object when you need it, you don't define it because you may need an instance later
The idea is that you would do
PizzaBase := Object clone (
tomato := true
eat := method(
writeln("eat", self))
)
# later in the code you need a pizza with anchovies
PizzaAnchovies := PizzaBase clone
# later in the code after you computed how many anchovies you want in the pizza
PizzaAnchovies numberOfAnchovies := 4
# later in the code you want your pizza with anchoives object to have also cheese
PizzaAnchovies cheese := true
You don't need a builder at all. the prototype inheritance is a generalized builder
> Yes you do.
Again, you don't
As a rule of thumb, the creational design patterns are all "workarounds" around the strictness of class based object construction
Since the receiver of an object doesn't need to know in advance the **class** of an object you don't need abstract object/concrete object machinery