SITECORE CMS: Add Dependency Injection In Your Sitecore Application

 



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.
  1. Constructor Injection
    This injector supplies the dependency through the constructor of the class. 

  2. 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.

  3. 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.

Comments

Post a Comment