Thursday, May 29, 2008

Another IoC Container?!?!

If you are not using IoC by now then you are probably struggling with or not doing TDD. I have been luckily enough to give a few containers a bash including Spring.Net, ObjectBuilder, Castle's Winsdor/MicroKernal and StructureMap.
Castle is currently my preferred option of the above as I find it easy to use and config, and when needed it has a couple of bonus features.
However there is another kid on the block, which I felt was probably coming.

You see most of the useable IoC container have a fair bit of bloat. Most of the time I just want to be able to say something like:

IFoo foo = Container.GetInstance();

That is it, Really! I don't care about all of the other stuff that goes on, I basically just want a glorified factory that can handle constructor and setter injection. 80% of the time, that is all I care about.
It just seems to be odd to have a huge framework hanging around, especially on smaller projects just to aid in loose coupling.

Well I guess there are others thinking the same thing, enter Ninject.
Light weight, simple syntax, no bloat and apparently pretty fast.
Check it out if you want DI without all the bells and whistles that you will probably never use.

2 comments:

Tim Barcz said...

Scenario: Greenfield project. You have to add an IOC container, is it Ninject or Castle?

Tim

Unknown said...

Hey good to hear from you Tim,
I am currently building a bunch of stuff, of note
A) a big SOA integration solution and
B) a pluggable .net solution generator.
Castle will certainly be going in the big project but I see Ninject as a perfect tool to go with the solution generator, great opportunity to try something new. As the little project is all TDD and still in VERY loosely coupled components (i.e. not coupled at all!), I have not used an IoC container yet, so... for the final app Ninject it is!

Cheers,
Rhys