Blog

Filter posts by Category Or Tag of the Blog section!

When to use dependency injection?

Thursday, 03 October 2013

In enterprise applications, when it comes to a large amount of data and different components and you are aiming for code reuse; there is a pattern named Dependency Injection to avoid tight coupling of object implementations and make the objects loosely coupled. It can be applied in any situation across the layers, but it doesn't mean that you should apply for DI everywhere!

 

If you don't need different implementation and different configuration Do not use Dependency injection. Although there are some related and of course older replacement patterns for DI such as abstract factory or container patterns, nut dependency injection makes the code testable as well, and it is one the biggest advantage of DI in compare to other similar patterns.

 

comments powered by Disqus