Infosys Microsoft Alliance and Solutions blog

« WPF - TextBox memory leak issue | Main | Move Sites Across Content Databases in MOSS using STSADM »

Microsoft and Dependency Injection

At last some exciting news from Microsoft P&P Group about Dependency Injection (DI) and Inverse of Control (IoC) patterns. Grigori Melnik, the product manager for Ent. Lib 4.0 announced the roadmap for Unity and Enterprise LIbrary 4.0. I have been a big fan of DI Containers and have been playing around with Castle Windsor and Spring DI Containers for quite some time now. If you are new to DI and IoC, I would suggest you to go through the article written by Martin Fowler. In a nutshell, Dependency Injection is all about writing loosely coupled and testable software. In fact earlier version of Ent. Lib. has been using ObjectBuilder as a Dependency Injection Framework but it never was a full blown DI Container. You can build (Theoritically at least. Although, in reality I am scared to even think about it) your own container using ObjectBuilder.

ObjectBuilder seems to implement all the patterns in the world like Builder, Strategy, Factories, Locator to name a few. It is quite a formidable and intimidating opponent to have a duel with and the lack of documentation makes matter worse. So after trying to master it for a couple of weeks, I gave up as there were already lots of other alternatives at my disposal(And Better ones from Open Source Communities, I admit). But with the anouncement of Unity now it seems that Microsoft has admitted the importance of a DI Container in order to build loosely coupled, flexible and testable software components. Still these are early days to state the real usability of the framework but after playing around with it for a few days, I will come up with my own viewpoints on it vis-a-vis other well established open source DI Containers.

One good thing about Ent. Lib. 4.0 is the fact that it is being re-architected to use DI (Read Unity) for all its application blocks which means you are free to use any container of your choice. More importantly we can now hope that Microsoft will come up more softwares in future which support pluggable architecture and a greater degree of flexibility. How this container is going to fare against a myriad of other well known open source DI Containers like Windsor, Spring, StructureMap etc. is still to be seen. But at least we can see a ray of light at the end of a dark tunnel. So hoping for the best while keeping my fingers crossed.

You can download the weekly drop of Unity Framework from here

TrackBack

TrackBack URL for this entry:
http://www.infosysblogs.com/microsoft-mt/mt-tb.fcgi/187

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)