Dependency Injection
ELI5 — The Vibe Check
Instead of your UserService creating its own DatabaseConnection (tight coupling), you pass the database in from outside: new UserService(db). Now in tests you pass in a fake database, and in production you pass the real one. Your service does not know where the database came from. That is dependency injection. Simple idea, huge consequences.
Real Talk
undefined
When You'll Hear This
undefined
Related Terms
Factory Pattern
You want to create a 'notification' object but it might be an EmailNotification, SMSNotification, or PushNotification depending on user preferences.
Inversion of Control (IoC)
Inversion of Control is when a framework calls YOUR code instead of you calling the framework. You don't control the flow anymore — the framework does.
Singleton Pattern
Singleton says: 'this class shall have exactly ONE instance, ever.' Database connections, config objects, loggers — things you only want created once.