← All Quizzes
What is the Dependency Inversion Principle (DIP)?
Explanation
The Dependency Inversion Principle (DIP), the D in SOLID, states that high-level modules should not depend on low-level modules; both should depend on abstractions. Abstractions should not depend on details; details should depend on abstractions. DIP is implemented through dependency injection, interfaces, and the Inversion of Control pattern. DIP decouples high-level policy from low-level details, enabling easier testing (mocking), swapping implementations, and maintaining business logic independent of infrastructure. Frameworks like Spring and NestJS are built on DIP.