SOLID & OOP Principles (50 Qs)•Part 3: Enterprise Architecture, Package Design & Enforcement (25 - 35)
Dependency Inversion Principle (DIP) vs Inversion of Control (IoC) vs Dependency Injection (DI).
senior LevelMost AskedDependency InjectionSystem Design
In Simple Words: Clarifying the three frequently confused terms:
- DIP (Architectural Principle): High-level business logic modules must not depend on low-level implementation modules (databases, APIs). Both must depend on abstractions (interfaces).
- IoC (Design Pattern / Concept): Inverting the traditional control flow. Instead of your custom code calling a framework library, the framework calls your custom code (the "Hollywood Principle": Don't call us, we'll call you).
- DI (Implementation Technique): The mechanism of passing dependencies into an object via constructor or setter rather than having the object construct them itself using
new Database().