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?
3 Answers
+ 2
Dependency injection is one method to achive dependency inversion.
+ 2
Hardware abstraction is done by drivers. And no - polymorphism is something completly different.
+ 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.