In this article I am going to explain what dependency injection is and how to achieve dependency injection using Microsoft Unity.
In this article I am going to describe an important principle, that is the last one: Dependency Inversion. When I was new to this topic I was searching Google for the accurate definition of this principle. I got several definitions but I found one from Wikipedia that is appropriate for this concept: In object-oriented programming, the dependency inversion principle refers to a specific form of decoupling software modules.
There are two main concepts of the Dependency Inversion Principle and these are: 1. The Dependency Inversion Principle (DIP) states that high-level modules/classes should not depend upon low-level modules/classes. Both should depend upon abstractions. 2. Abstractions should not depend upon details. Details should depend upon abstractions. Dependency injection is a technique to develop software in an independent way. Independent in the sensethe no module will depend on another module in the software development. Sothe dependency injection technique will inject all dependencies of lower modules and provide these dependency to the higher module without direct contact. High-level modules/classes implement business rules or logic in an application. Low-level modules/classes deal with different operations; in other words, they may deal with writing information to databases or passing messages to the operating system or services, etc. The fully dependent application will look something like this. All modules are tightly coupled with each other. As per Dependency Inversion Principle there is someone between them to decouple these models. Here now I will explain how we can implement this in our MVC Project. Dependency Injection using Microsoft Unity
Exploring Design Pattern for Dummies