Factory Pattern
ELI5 — The Vibe Check
You want to create a 'notification' object but it might be an EmailNotification, SMSNotification, or PushNotification depending on user preferences. A Factory handles the 'which one?' decision for you. Your code asks the factory for 'a notification' and the factory figures out the right class to instantiate. Clean, extensible, closed to modification.
Real Talk
undefined
When You'll Hear This
undefined
Related Terms
Dependency Injection
Instead of your UserService creating its own DatabaseConnection (tight coupling), you pass the database in from outside: new UserService(db).
Singleton Pattern
Singleton says: 'this class shall have exactly ONE instance, ever.' Database connections, config objects, loggers — things you only want created once.
Strategy Pattern
You're writing a sorter and want to sort by price, name, or date depending on user choice.