| What is Dependency Injection in c#
First of all we learn what is Dependency Injection. Its a design pattern which helps us to create a loosely coupled software components. Or we can say that its help us to reduce the tight coupling between the software components. Which helps us to reduce the complexity of our applications.
Now before going in details we will learn something about Tight Coupling. Tight Coupling means classes and objects are dependent on each other. To understand this we will take another logic when one class is dependent on another concrete class
then it is said that tight couple in between these 2 classes. If we want to change dependent object then we also need to change the classes where dependent object is used. For small application it is easy to do that but for large application it is very difficult to handle these changes.
Now comes to Loose Coupling. When two objects are independent of each other means if one object is changed will not effect another object then this is said loose coupling. With the help of loose coupling changes in future can easily adopted and done and also helps manage to handle the complexity of the application.
DI (Dependency Injection) design pattern in c# is a Process in which we were injecting the object of class into a class that depends on that object. Dependency Injection design pattern is the mostly used design pattern nowadays to remove the dependencies between the objects. | | |