What is Dependency Injection?
DI is a software design pattern that will allow developers to develop loosely coupled codes between two components. It allows better management for future changes.
Better management allows for a better unit testing process and increases code reusability and maintainability.
There are a few ways of implementing DI.
- Constructor Injection
This injector supplies the dependency through the constructor of the class. - Property Injection
Injector supplies dependency through the setter of the property of the class. As this is being done through Setter, this is also called Setter Injections. - Method Injection
Over here client class implements an interface that declares the method to supply the dependency and using this interface the injector supplies the dependency to the client class.
This article still needs improvements..
ReplyDelete