DEV Community

loading...

Discussion on: Explain Factory Pattern Like I'm Five

Collapse
gi_decuzzi profile image
Gisela

You are in an icecream parlour where you can choose between 100 flavours and 50 toppings, but usually the clients want a sundae chocolate & vanilla!
So you can do a fast line where you say "the classic" then you obtain your sundae with chocolate and vanilla insted of making the slow line and specify everything detailed.

With code:
IceCreamParlour.theClasic()

vs
i = new IceCream();
i.presentation(SUNDAE)
i.addFlavour(chocolate)
...