There were quite a few comments on my last post telling me that I was confusing the following terms:
- Inversion of Control
- Dependency Inversion (Principle)
- Dependency Injection
So I thought I’d attempt to clarify things. Check out this Wikipedia article:
"Inversion of Control is highly associated with dependency injection and the dependency inversion principle. Dependency injection is the main method to implement Inversion of Control."
As I understand it Inversion of Control and the Dependency Inversion Principle are both different names for the same 'principle' of OO design. That you should decouple your software by depending on abstractions rather than implementations.
Dependency Injection is a 'pattern' used to implement Inversion of Control/Dependency Inversion. This is either implemented as constructor injection, where dependencies are ‘injected’ via constructor parameters, or as property injection where dependencies are injected via property setters.
This is just my understanding of these terms. If you think I’m wrong please comment and maybe we can arrive at some accepted definitions.