DEV Community

Discussion on: Explain Factory Pattern Like I'm Five

jmtiong profile image
Jia Ming • Edited on

After reading through the rest of the comments, this is what I came up with. Please correct me if I am wrong!

You want to eat an ice cream with 2 scoops of flavors, mint and strawberry. On top of that, you want to drizzle it with chocolate sauce and be placed in a waffle cone. For this to happen, you have to do it all by yourself, adding the stuff you want one by one.

For Factory Pattern, you go to the ice cream shop and say, I want an ice cream with 2 flavors, mint and strawberry, drizzled with choclate sauce and place it in a waffle cone. Without you doing anything, BOOM! You got what you want.

Edit: From now on, whenever you want a particular ice cream, all you have to do is to tell the ice cream shop what you want, instead of creating it yourself