What IoC Container do you use?

I often get asked what IoC Container I prefer.  Short answer: StructureMap. I love the fluent syntax for configuration. Overall, it’s easy to use, has many advanced features, and is very lightweight.  I view the learning curve with StructureMap as relatively small.  It is one of the longest-lived IoC containers (if not *the* longest) and has a huge adoption rate which means it’s quite mature and not difficult to find code examples online. For example, there is the StructureMap mailing list. Additionally, the community is very proactive – I just sent an email question to Chad Myers today and got a response within minutes that solved my issue. The creator of StructureMap, Jeremy Miller, has one of the most useful blogs around (in addition to his column in MSDN magazine).

Despite all this, there are still several other very high quality IoC containers available including: Unity, Ninject, Windsor, Spring.NET, and AutoFac. Unity is Microsoft’s offering in the IoC space and often it gets picked simply because it’s got the “magical” Microsoft label on it.  In fact, some organizations (for better or worse – usually worse) have policies *against* using OSS software and your only choice is to look at the offerings on the Microsoft platform.  Despite this, Unity is actually pretty good but by P&P’s own admission, there are instances where StuctureMap implementation is a little more elegant than Unity. But Unity does still have some compelling reasons to use it. In fact, if you are already using the Microsoft Enterprise Library Application Blocks, choosing Unity makes sense for a little more seamless experience.

Having said all this, there is one other major caveat to my preference towards StructureMap – it’s the IoC tool I’m most familiar with. Therefore you should take a recommendation from me (or *anyone*) with a grain of salt.  Ultimately the features of the various IoC’s are going to be comparable and it’s the developer familiarity with that tool that is going to make the difference.  For folks new to IoC, most of the uses are going to be for simple constructor dependency injection and all the IoC frameworks can handle that easily.  Given the wealth of quality IoC frameworks, we need another IoC framework about as bad as we need another data access technology. :)

posted on Wednesday, October 14, 2009 3:22 PM Print
# re: What IoC Container do you use?
10/14/2009 8:06 PM
Apart from the 'Known Devil' preference, the help page of 'StructureMap' has very good articles targetted for newbie IoC and Dependency Injection learners which wins a lot of adopters.

The 'fluent' syntax and the value posts by 'Jeremy Miller' and gang make 'StructureMap' the 'jQuery' of 'IoC Containers'

# re: What IoC Container do you use?
Patrick Veverka
11/30/2009 7:47 PM
I had tried out nInject before and it's a very strong contender. We're using StructureMap on a few internal projects because it seems a bit easier to pick up and, like you said, it has been around longer which means better examples online.

Post Comment

Title *
Name *
Comment *  

View Steve Michelotti's profile on LinkedIn

profile for Steve Michelotti at Stack Overflow, Q&A for professional and enthusiast programmers

Google My Blog

Tag Cloud