Getting Bent Out of Shape Over Inversion of Control (IoC)
December 30th, 2008 RustyI find I often spend more time trying to choose between alternative frameworks then I do either identifying the need for one, or designing and implementing the solution. For example, I spent quite a bit of time evaluating competing blog engines. When I finally chose WordPress, the install took a fraction of the time that I spent researching various alternatives. Anyone who has used WordPress can attest that there really is no learning curve to using it and it installs ready to blog. The funny thing is, I knew before I had spent any time researching that WordPress was the most popular blog engine out there. Why? who cares? Move on already.
Most Popular IoC Framework
It wasn’t nearly so cut and dry for IoC in dotnet. I found quite a few resources evaluating and comparing various frameworks but nothing really conclusive. Then I realized that most of the tech bloggers I follow tend to use the same tools that I find most valuable. Much of the time its because they turn me on to them.
I decided to narrow my search to my most respected bloggers. I started out with Scott Hanselman but he’s off wandering about Africa and has just started looking into IoC himself (or hasn’t updated his captive audience on his progres in a while). His blog, however, did lead me in the right direction. He was kind enough to post a list of the current dotnet IoC projects that look attractive/viable. Sometimes a list helps to get the Googling going. A short while later, I was reading posts by Ayende Rahien. He’s a somebody I’d like to buy a few rounds of shots for. He’s helped me more than probably any other Microsoft technologist. He got straight to the meat and stated that he prefers Windsor Container (because that is what he has used). Good enough for me! Ironically, that is what I was going to use when I started my research but didn’t want to "make a regrettable choice". What lead me astray is that Microsoft has recently promoted their framework called Unity. If you are the kind of developer or development shop that prefers supported software or you just lean toward Microsoft code, use Unity. It will get the job done. From my perspective, Windsor is mature, stable, simple and natively supports AOP.
Generally Trust in People but Still Lock Your Doors
I trust people in general but I never leave valuables in my car. With code, that strategy can be applied in this way: use what is most convenient to solve your immediate need but loosely couple. The whole point of IoC is loose coupling. I wish I had just committed to keeping my registration code abstracted from any consumer access jumped into Windsor rather than spent all day obsessing about which framework was better. Blogging about it tonight took about an hour. I should have my code finished in about fifteen minutes. At least I feel good about my decision.