|
|
|
|
|
by flavius29663
1740 days ago
|
|
pizza is very suitable for the builder pattern:
CreatePizza()
.WithBacon()
.With(artichoke)
.Build(); or any combination of the above:
CreatePizza()
.WithMussroom()
.Build() Even better, you can add new ingredients without changing any of the existing signatures:
CreatePizza()
.WithProsciuto()
.WithTomatoSauce()
.Build() |
|
createPizza({bacon: true, artichoke: true});
This has the same benefit you describe of being able to add parameters without altering any old call sites
createPizza({prosiuto: true, tomatoSauce: true});