SOLID & OOP Principles (50 Qs)•Part 1: Core SOLID Principles & Fundamentals (1 - 10)
What is the Dependency Inversion Principle (DIP) and how does it differ from Dependency Injection (DI)?
junior LevelMost AskedDependency Injection
In Simple Words:
- Dependency Inversion Principle (DIP - The Design Principle): High-level business logic modules should not depend on low-level modules (e.g. databases, HTTP clients); both should depend on abstractions (interfaces).
- Dependency Injection (DI - The Implementation Pattern): A technique where an object receives its dependencies from the outside (e.g. passed via constructor) rather than creating them internally using
new Database().