DEV Community

Discussion on: Builder Design Pattern

Collapse
 
schlump_fuffzn profile image
Stefan Hecker

Aren't you duplicating the set of Boolean parameters? Why not create an instance of Burger in the BurgerBuilder constructor and return it when calling build().
Oh, I see, that way Burger won't be immutable.

Collapse
 
nishparadox profile image
Nishan Pantha

Yeah. The whole point is to avoid the constructor of Burger being populated. This way, it will allow you to create chained calls to the builder and yes the side effect is the immutability of Burger subsequently.