Dependency Injection Inversion
Seems there is still a lot of confusion about what is Inversion of Control, what is Dependency Injection, what are the differences between the two, and how to apply one or the other properly.
Several people have reacted to a controversial post by Uncle Bob on that topic with, among the most vocal ones, Davy.
IMHO, some of the best posts on the subject that really make a clear distinction between IoC & DI are the following ones:
- Inversion of Control != Dependency Injection
- On Inversion of Control
- A small excerpt from the IoC Container doc
The whole point of IoC (forget a minute about DI) is to break the dependencies between your classes and design them asĀ loosely-coupled as possible (to the point that it’s actually useful of course, it’s not an engineering contest).
All the benefits that you get:
- Dependency Injection
- Better testability
- Better maintainability
are just consequences of the good design of your classes (read about SOLID also).
In the end, it’s just good Object-Oriented design, nothing more. And by good, it doesn’t mean complex, it’s actually quite simple once you got it.
