โ† CS Visual Lab ยท Design Patterns

๐Ÿญ Factory Method

๐Ÿ’ก The ideaCreate objects through a method instead of calling new directly, so the caller does not depend on the exact class.
๐Ÿ  In real lifeYou order "a pizza" at the counter; the kitchen decides which pizza class to make. You never go into the kitchen.

๐ŸŽฌ Watch it work

Step 1 of 4
A common interface

All products share one interface.

interface Notifier { send(to: string, msg: string): void }

โœ… Check yourself (2 of 3 to pass)

1. Factory Method mainly helps to:
2. Factory Method is a โ€ฆ pattern.
3. Adding a new product type usually changes:
Next: Observer โ†’Get a free certificate in Design Patterns