โ 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 }