Search code examples
c#containersinversion-of-control

C# IoC containers


I've always used C# interfaces to achieve inversion of control. But then I found this article which compares a bunch of IoC containers. What is the difference between these containers and a C# interface?

http://www.palmmedia.de/blog/2011/8/30/ioc-container-benchmark-performance-comparison


Solution

  • You make a false comparison. Abstractions are a prerequisite to apply Dependency Injection and to conform to the Dependency Inversion Principle. If you are applying DI without the help of a container, you are practicing Pure DI. Pure DI is a valid practice.

    When an application grows, the use of containers can become very convenient, because they enable Convention over Configuration to wire object graphs. If you start using a DI container, you still need to use Abstractions.

    To learn more on when and why you should use a DI container, read this and this.