Dependency Injection Principle (DIP) - Inversion of Control (IoC)

The principle states:

  1. High-level modules should not depend on low-level modules. Both should depend on abstractions.
  2. Abstractions should not depend on details. Details should depend on abstractions.

The first point suggests we apply two things at the same time to the codes:

  • Abstraction (e.g. Interfaces, Abstract Classes, etc)
  • Dependency Inversion or Inversion of Control (e.g. passing dependencies through constructor args)

Implementations