I am a big fan of Inversion of Control (IOC) containers. I strongly believe when used correctly they clean up your code by at least 30% . They also help you understand your dependencies much better.
There are many options for developers when choosing an IOC, of which most have extensive material, samples and documentation available. Recently I was wondering what are the dependencies of an IOC container. After all, they help apply the dependency injection pattern, but what do they in turn rely on. To help with this exercise, I am using a tool called NDepend. This is similar to the dependency mapping available in the Beta of VS2010 but on steroids.
I took two containers that I am familiar with. The Microsoft Patterns and Practices implementation Unity, and the popular open source project StructureMap.
The first thing we notice about both frameworks is that they have little need to go outside the basics of the .Net framework. As such they are both great candidates for any type of application, be it Web, WPF or services.
| Unity | Structure Map |
 |  |
Delving a little further, we find that both frameworks are similar in the namespaces they consume. Both making strong use of generics (to be expected), however Structure Map has some a fluent configuration options and so makes use of Linq. It also has some specific implementations (Pipelines) that cover specific lifecycles such as ASP.Net.
| Unity | Structure Map |
 | |
Comparing components in this way gives you a better understanding of what is under the hood. This is just a quick overview of looking at frameworks and their dependencies. Next time that you use a framework, it might be worth considering what other components and dependencies you are inheriting.
Get Amongst It!!!!