I have been using IoC for a little while now and I am curious if I should use Microsoft's Unity framework (official name "Unity Application Block"). Does anyone have experience using it? So for I have been copying my IoC container code from project to project, but I think it would be better to using something standard. I think IoC can make a HUGE difference in keeping component based applications loosely coupled and therefore changeable but I am by no means an expert on IoC, so I am nervous to switch to a framework that will just paint me into a corner as a dependency I will one day want to walk away from.
You should not use IoC/DI where you cannot demonstrate concrete examples of how the complexity added through the use of IoC/DI is out weighed by the benefits of using IoC/DI.
Inversion of Control (IoC) is a design principle that allows classes to be loosely coupled and, therefore, easier to test and maintain. IoC refers to transferring the control of objects and their dependencies from the main program to a container or framework.
Unity is one among the Microsoft Application Blocks. It is basically introduced as an IOC container by Microsoft, which helps in easy object creation and de-coupling the module dependencies in your project. To use it, just add the reference of the Unity DLLs to your project.
Unity Inversion of Control (Unity IoC) Inversion of Control (IoC) is a concept stating that aggregated system modules should not depend on implementation of subordinate modules. Instead, a separate module-container stores abstraction-implementation couple and manages the lifetime of these implementations.
I am using Unity with no real problems. I know a few ALT.NET type people warn against Unity but I really think that is just because of the history the MS P&P team have of writing bloatware. Unity is not yet bloated IMO and works well.
I took a look at the Unity Framework, but found it to be a little 'too big' for my needs (no, I can't really quantify that, it just seemed to require much more knowledge that other frameworks that I've been playing with... this was a while ago so it's possible that that's changed as Unity's been developed/refined).
My current IoC/Dependency Injection framework is Ninject. It's quick, fast, and I was able to go from reading the tutorials (about 10 minutes) to using it in a pre-existing project in about two hours.
If you're looking for a clean way to do dependency injection, I'd highly recommend checking it out.
I would say stick with the one you know until you feel confident with it and the whole concept. After what you'll have a better judgement to pick a framework which fullfill your needs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With