views:

1894

answers:

5

Which is the best IoC among StructureMap and Ninject?

This should be merged with: Best injections frameworks

+6  A: 

Depends on the situation. For small projects where you need a simple container I'd choose Ninject. I like the fact that it's small and lean. I dislike the attribute's but there are ways around that.

For a big solution where you might need more than simple IoC i'd go with the Castle stuff. Lot's of flexibility there, you can use xml, attributes or a DSL to configure stuff, you can expand your IoC into AOP territory if you need it later.

I havn't tried structuremap yet. It seems it does a lot more than IoC. But I can't comment on it. I'd think that Ninject and Structuremap serve different purposes so it's hard to choose between the two without knowing a little bit more about the context. Better is usually a relative concept :-)

Mendelt
+1  A: 

I use StructureMap so I probably think it is the best. But perhaps in future I would go for Unity since that is MS supported, which means better documentation and less dependent on the goodwill of one person allthough that person is very goodwilled. Of course I won't be changing framework just because it's nice. As long as something works I don't even upgrade.

chrissie1
I'm having trouble finding any documentation for Unity. Could someone provide a link?
StriplingWarrior
+2  A: 

There is no best. Most of them do 90% of what you need in pretty much the same manner. In certain situations, one might be more flexible than another.

Given the choice I'd pick Windsor, if nothing else but I already know it pretty well. But I wouldn't gripe if I had to use Ninject or StructureMap. They're both good frameworks.

I know that currently Ninject is the only one that will run on Compact framework, so if that's a req. then Ninject is the way to go.

I'm a tad scared of Spring.NET, mostly because I loathe XML. But maybe it's not as bad as I think, don't flame me :)

Ben Scheirman
+2  A: 

I'm going thorugh this process myself. I would recommend kicking off with ninject. Just because it is so lightweight and has a really low entry level. You can have it up and running in a matter of hours.

What you will find is that you will design your system with IoC in mind and that design will be largely the same regardless of the IoC framework you use.

Without too much re-work beyong the basic framework plumbing you should be able to swap out NInject for something like StructureMap if you want to.

Your best bet is to get going with one and see what issues you find and then decide whether an alternative would suit your needs better.

The frameworks out there do seem to be going through a dynamic period with new versions being released all over the place. And MEF, which is IoC and much more, may force further change of the landscape.

objektivs
+1  A: 

autofac is a nice choice for small projects. If you want hardcore IoC + integration with whatever you can imagine, I'd recommend Spring.NET

Anton Gogolev