Wednesday, June 7, 2017

Dependency Inversion Principle

Dependency Inversion Principle basically says that when a class A depends on class B, do not instantiate class B in class A. Instead create a interface I that class B can implement and make class A depend on the interface I. This way we can plug in any other classes that implement from interface I in class A.

Basically the code should depend upon abstractions. By depending upon abstractions, we are decoupling implementations from each other.