Skip to content

Month: August 2017

Dependency Injection using Autofac

In the previous post, we saw how we can inject dependencies without any DI container. However, in this post, we will see how DI containers help us by instantiating the dependencies and provide them whenever and wherever required.   What is a DI Container? In the example for our last post, we had to instantiate dependencies on our own, before injecting them via constructor. Consequently, as…

Dependency Injection – without DI Container

Now that we have the answer to our question, why loosely coupled code?, let’s try and solve the problems we found in a tightly coupled application. In this post, we will use constructor based dependency injection, however, we are not going to use any DI container for now.   Dependency Injection Dependency Injection (DI) is a technique that helps us achieve loose coupling between objects and…

Implicit vs Explicit Dependencies

If our class depends upon other classes to complete its operations, then these other classes are dependencies for our class. Our class can have these dependencies as implicit or explicit dependencies. What does this mean? What effect does it have on our application design? Let’s try to find answers to these questions.   Implicit Dependencies The dependencies are implicit for a class, if they exist only in the code within…

5 Reasons to write Loosely Coupled code

In the last post, we analyzed a tightly coupled application and listed out the problems we found with the same. In this post, we will explore, how writing loosely coupled code helps us keeping our applications easy to write, test and maintain.   Introduction A loosely coupled application has good isolation among its classes, modules and assemblies. Therefore, if we make a change to one part…