intermediateSOLID Principles

What is the Dependency Inversion Principle, and how does it differ from Dependency Injection?

Dependency Inversion is a design PRINCIPLE stating that high-level modules shouldn't depend on low-level modules directly — both should depend on abstractions (interfaces). Dependency Injection is a PATTERN/TECHNIQUE for actually supplying those dependencies (typically via constructor) from the outside rather than a class creating them itself; using DI doesn't automatically guarantee DIP — you can inject a concrete class directly instead of an interface, which still violates the principle even though the dependency is technically 'injected.'

This is a Pro question

Sign in, then upgrade to Pro or Power to unlock this question and the full Interview Prep bank.

What is the Dependency Inversion Principle, and how does it differ from Dependency Injection?

Next Step

Continue to What is the difference between aggregation and composition?← Back to all Design Patterns & LLD questions