CSC/ECE 517 Fall 2009/wiki3 5 rm: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 11: Line 11:


'''High Level Classes → Abstraction Layer → Low Level Classes'''
'''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.
[[Image:wiki3_5_rm1.png|450px|thumb|center|Figure 1: Higher-level components depend upon lower-level components]]

Revision as of 17:21, 18 November 2009

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:

  1. High-level modules should not depend upon low-level modules. Both should depend upon abstractions.
  2. 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.

Figure 1: Higher-level components depend upon lower-level components