Do we achieve Dependency Inversion Principle using Dependency Injection technique?
Am I correct?
2 Answers 2
Yes. Dependency inversion says "do not seek your dependencies yourself, they will be supplied to you." Dependency injection is a way of supplying the dependencies to the object from the outside.
2 Comments
yes it is
The Dependency Inversion Principle in two sentences:
High level modules should not depend upon low level modules. Both should depend upon abstractions.
and
Abstractions should not depend upon details. Details should depend upon abstractions.
while
The Dependency Injection Pattern is one of the concrete solutions to the application/code composition problem. And yes this solution is implementation of the Dependency Inversion Principle. Probably the most known place to read is Martin Fowler - Inversion of Control Containers and the Dependency Injection pattern.
2 Comments
Explore related questions
See similar questions with these tags.