CSC/ECE 517 Fall 2009/wiki3 5 rm
Dependency Inversion policy
Introduction
The Dependency Inversion Principle has been proposed by Robert C. Martin. It states that:
"High level modules should not depend upon low level modules. Both should depend upon abstractions. Abstractions should not depend upon details. Details should depend upon abstractions."
The principle is reverse the conventional philosophy of high level functions in softwares need to depend on the low level functions. The principle states that high level or low level modules should not depend upon each other, instead they should depend upon abstractions. Further it also states that these abstractions should not depend on the details and inversely the details should depend on the abstractions. According to this principle the way of designing a class structure is to start from high level modules to the low level modules:
High Level Classes → Abstraction Layer → Low Level Classes
Overview
The Dependency Inversion Principle is defined as follows:
- High-level modules should not depend upon low-level modules. Both should depend upon abstractions.
- Abstractions should not depend upon details. Details should depend upon abstractions.
The problem with the conventional design architecture is that the higher level components depends on the lower level components. This can be understood from the diagram below.