One Line Statement
If you do not know what IoC is, you might want to check sample articles:
- The semi standard Dependency Injection (DI) and Inversion of Control (IoC) article by Martin Fowler (Tip, read as much as you can from this guy’s writings – and thank me for suggesting it) [Warning: Not .NET Specific]
- Understanding IoC Container (Simple "down to code quickly" introduction by Sean Feldman)
- IoC Page on Wikipedia [Warning: Not .NET Specific]
- A sample DI and IoC presentation (By my friend Mohamed Nour)
I have been interested in Dependency Injection (DI) and Inversion of Control (IoC) for few months, and I brought other guys interested too such as Mohamed Nour :D. I’m not going to discuss when I believe those strategies should be used, and how they relate to each others (at least not in this post).
The usual story
If you know about IoC, you’d know that there’re few big players in the field that are speaking .NET. I’ll not compare them here. I’m not even talking about them with relevance to time order, but I like to see how the "vendors / characteristics" map looks like. For comparisons, check the end of this section.
The usual story, a player coming from Java world, moving from Java’s Spring to .NET’s Spring.NET. As you’d expect, this is the one mostly in love with XML configurations – too much of them sometimes, but, it’s the most mature one.
Then, as for everything coming from other worlds, Castle group/project was interested. They had their own player, Windsor. Windsor is of course less XML-ish, and as you may expect, it fits best in combination with other Castle stuff. As usual with Castle, the documentation is way far from complete, however, a funny joke about it is someone saying that a big feature of Windsor is that Ayende blogs a lot about it!
Also as usual, there had to be an individual player who tries to do the thing from scratch. That was StructureMap.
For a true comparison between those players, check the following articles:
- List of .NET Dependency Injection Containers (IOC) (By Scott Hanselman)
- Very simple and quick comparison between the players (Not so accurate but gives you a quick feeling of the thing – By Doug Seelinger)
Here comes Microsoft
As happened with AJAX and unit testing frameworks, when Microsoft decided to create it’s own game into the scenes, Microsoft has come to this ground as well to make its standard flavor, going with the relatively recent strategy of not trying to kill the existing players (The proof is approving supporting them in ASP.NET MVC Framework).
Microsoft IoC container as usual had a unique characteristic, and as usual, the unique thing is related to integration with more MS stuff. The Unity IoC container is actually an Enterprise Library Application Block. It’s meant to be part of Enterprise Library 4.0. Although Enterprise Library 4.0 is not "released" yet, The Unity Application Block itself is done 1.0, and available to download and use.
Being part of the Enterprise Library (and being an IoC container in general actually – LOL), it didn’t escape the XML configuration hassle. Again, that’s (unfortunately) a necessity for any IoC. For more information and examples on using Unity, check any of the following articles:
- Unity Application Block Official MSDN Page (You must have expected it)
- IoC and Unity – The Basics and Interception (Very detailed take on the topic by Matthew Podwysocki) – This one really interesting guy to monitor as well, keep you bookmarklet/RSS Reader ready!)
- Patterns & Practices Guidance Link Collection – Those link to Screencasts and GREAT tutorials and samples – One other place to keep an eye on generally
- Articles and Screencast on Unity with ASP.NET MVC Framework (By David Hayden)
- BTW, the Unity CHM file (found on the release page) is a really good one – Trust me!
Create you own (Just for fun!!)
If you want to see how this thing from inside looks like, and you do not have time to investigate the source code of a sophisticated IoC container from any of the big players, check Ayende’s Building an IoC container in 15 lines of code article. But do not expect that to make you one more player :D.
You can also check how you can try achieving very basic functionality with the existing components of the BCL – that was before Unity of course :).
P.S. Please help me out by checking this offer, then look below for a small Thank You.
How did I learn that?
As a bonus for coming here, I'm giving away a free newsletter for web developers that you can sign up for from here.
It's not an anything-and-everything link list. It's thoughtfully collected picks of articles and tools, that focus on Angular 2, ASP.NET 5, and other fullstack developer goodies.