see also Which C#/.NET Dependency Injection frameworks are worth looking into?
There are now many dependency injection frameworks to choose from. You used to often be forced to use a given dependency injection framework due to a library you were using. However the Common Service Locator library has enabled library code to be independent of injection frameworks.
The time it takes to learn all of them well enough to decide which to use is unreasonable. I don’t believe that we have yet reached a stage that we can talk about the best dependency injection framework. So what questions should I be asking about the project and myself to help decide on the best dependency injection framework to use in a given case?
It would also be useful to know why you choose the dependency injection framework you are currently using and if you are still happy with that choose.
Is there yet a useful vocabulary to use when comparing the styles of dependency injection frameworks?
Does the Service Locator library work in real life, or are you skill forced to use lots of different dependency injection frameworks in the same project?
How easy is to refractor you code with each Dependency Injection Framework, e.g do tools like ReSharper work well with a given framework?
NET supports the dependency injection (DI) software design pattern, which is a technique for achieving Inversion of Control (IoC) between classes and their dependencies. Dependency injection in . NET is a built-in part of the framework, along with configuration, logging, and the options pattern.
You dont have to have a DI framework, but at some point in your codebase a concrete implementation is going to need to be instantiated and injected into your constructors/properties.
Dependency injection (also known as DI) is a design pattern in which a class or object has its dependent classes injected (passed to it by another class or object) rather than create them directly. Dependency injection facilitates loose coupling and promotes testability and maintenance.
FYI, just this morning I came across an interesting comparison between all the .NET IoC containers here:
http://elegantcode.com/2009/01/07/ioc-libraries-compared/
A handful of questions:
On a personal note:
I've used StructureMap for the same reasons mentioned in the blog I linked. I think XML config is a giant pain to maintain and, especially, debug (see WCF). I haven't tried Ninject yet, but based on their marketing, it must be super rad!
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