What is the difference between dependency injection and dependency inversion? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 9

What is the difference between dependency injection and dependency inversion?

Are they the same thing? Are they ways of abstracting out hardware or other interfaces? Are they just fancy names for polymorphism?

11th May 2019, 5:21 AM
Sonic
Sonic - avatar
3 Answers
+ 2
Dependency injection is one method to achive dependency inversion.
11th May 2019, 6:45 AM
Daniel Adam
Daniel Adam - avatar
+ 2
Hardware abstraction is done by drivers. And no - polymorphism is something completly different.
11th May 2019, 6:46 AM
Daniel Adam
Daniel Adam - avatar
+ 2
Dependency injection is a technique whereby one object (or static method) supplies the dependencies of another object. A dependency is an object that can be used (a service) while Dependency Inversion is one of the last principles we are going to look at. The principle states that: High-level modules should not depend on low-level modules. Both should depend on abstractions. Abstractions should not depend on details.
12th May 2019, 1:33 PM
eMBee
eMBee - avatar