G.Dependency Inversion Principle (DIP)

  1. Summary

    1. Both High level and low level modules should be dependent on a common abstraction or interface

    2. Usually most of class diagrams are designed from top to bottom and but there is an OO principle “Be dependent on abstraction instead of concrete classes” that reverse this diagram and that is called dependency inversion.

      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.

  2. Applicability

      1. Interface Design

  1. Example

    1. Pizaa Store Design

  1. Related Concepts

      1. Inversion of Control (IOC) : A Design Guidelines that further augment DIP

      2. Dependency Injection : One of the approach to achieve IOC

      3. Service Locators : Another approach to achieve IOC

      4. Factory Pattern : A design pattern that implement IOC

  2. References