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:
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.
Go & take the time to read those posts about the latest drop (preview 5) of MEF (Managed Extensibility Framework):
All of this will come for free as part of .Net 4.0 … isn’t that cool or what?
A quick post to link Hammett's (creator of Castle Project, Windsor IoC container, and now PM on the MEF project) very interesting article about Dependencies, ownership & lifetime of components.
I've been quite busy lately which explain the very few & mostly news-aggregating posts I've written:
- Opportunity 1 : Late June, I had the pleasure to pass an interview at Microsoft, in Seattle, for a position of Program Manager on the MEF Team. I met very bright people and had very interesting conversations (and played with Microsoft Surface !!!
), and although I wasn't chosen (I simply wasn't good enough but I'm working on it
I'm a positive guy), I view it as a great experience in my professional career. I later was very happy to learn that Hammett was hired for the position … this guy is a genius. I was already enthusiastic about MEF before, but now I cannot wait to see the outcome.
- Holidays : difficult to concentrate on work when the sun is out and you got family & friends to got out with …
- Opportunity 2 : I quit my company where I was working as a .Net consultant to join a small team of very talented people working on a great project. Cherries on the cake, I'm going to work close from home and for the first time in my life, buy my own car.
- Beers : when it's sunny & warm in Belgium, Belgians drink a lot of beers (actually, they also do even when it's not sunny but that's another story … and you probably don't care about it
lol … Except that the guys of the Dutch Alt.net group have invited Ayende to share some good belgian beers on Tuesday, the 5th August in Brussels. I'll be there and I'm eager to see what kind of interesting conversations geeks can have after a few Leffe Blonde, Duvel, Kwak, Chimay … lol
Couldn't make it, too busy.
All in all, a great period with lots of changes … I'll be back with (I hope) interesting posts, about Entity Framework most notably, around mid-August. See you then !
The MEF Team has just released its first CTP of the Managed Extensibility Framework.
This is a project to keep an eye on as it will bring Dependency Injection (and much more) right at the heart of the .Net Framework, in a new System.ComponentModel.Composition namespace (still subject to change).
The project page is here. The CTP contains some very nice demos of the early possibilities.