Dependency Injection is a shamefully under-utilised practice in .NET development. There’s really little excuse for this as there are a number of serviceable frameworks available. These include Castle Windsor (http://www.castleproject.org/container/index.html), Spring.NET (http://www.springframework.net/) or even Unity (http://unity.codeplex.com/) if you’re stuck at a Microsoft-only shop. However my personal preference is StructureMap (http://structuremap.github.com/structuremap/) which has a number of features that I like:
- Simple deployment There’s a single StructureMap assembly to be referenced and it’s rare to encounter a situation where you need multiple incompatible versions.
- Minimally intrusive StructureMap doesn’t require the use of attributes, marker interfaces or base classes to work with your types.
- No XML XML configuration for dependency injection is difficult to write, maintain and debug. StructureMap can support XML where necessary but most configuration occurs through code.
- Convention based configuration StructureMap includes by default powerful mechanisms to apply convention based configuration to your DI setup. Once these conventions are established you can largely forget it’s there.
- Stable and mature StructureMap has been around longer than any other .NET DI framework and has the stability and maturity you’d expect from such longevity.
- Well thought out API The StructureMap API has been heavily refactored over time to produce something powerful, readable and highly expressive.
This is the introduction to a series of posts I’m writing to introduce StructureMap. My driver for this is to get a new team up to speed with it for a current project but I’m writing for a more general audience. I hope someone find it useful (or at all).
Index