Sunday, November 25, 2018

Dependency Injection


This article discusses Dependency Injection as a design pattern and as a part of the SOLID principles.

Dependency Injection is a software design pattern. In other words, it is a technique of structuring the code of an application. The technique implements inversion of control.

Dependency Injection is also a principle belonging to the set called SOLID:
  • Single Responsibility Principle (SRP)
  • Open Closed Principle (OCP)
  • Liskov Substitution Principle (LSP)
  • Interface Segregation Principle (ISP)
    • Dependency Injection (DI)
    • Inversion of Control (IoC)
  • Dependency Inversion Principle (DIP) 
Most often, however, DI is regarded as a realization of the IoC paradigm.

Dependency Injection allows us to create code which is loosely coupled. This term is best understood by defining its opposite: tight (or heavy) coupling. In computer software, tight coupling means that the software is dependant on other software in order to work properly. 

No comments:

Post a Comment