Dependency inversion principle

From Wikipedia, the free encyclopedia

The Dependency Inversion Principle (DIP) is sometimes regarded as a synonym for inversion of control. However, dependency inversion can be thought as a more simplistic constituent of the larger concept of inversion of control. [1]. This principle seeks to "invert" the conventional notion that high level modules in software should depend upon the lower level modules. The principle states that high level or low level modules should not depend upon each other, instead they should depend upon abstractions. The advantage of a design with Dependency Inversion Principle in mind is that you do not have to develop the lower level modules before developing the higher level modules. Thus a top-down approach is possible in both design and development. The result is that components are less tightly coupled, and there is a high degree of separation of concerns. The individual components are more easily testable and the higher level objects can be tested with mock objects in place of lower level services.

Contents

[edit] DI and Unit testing

Due to the fact that the higher level components are not coupled with the hard-to-simulate low level functionality, DI is complementary to the unit testing strategy using automated unit test generation and execution.[2]

[edit] References

  1. ^ Dependency Inversion Principle EventHelix, Retrieved on 13 February 2008
  2. ^ TDD Design Starter Kit - Dependency Inversion Principle CodeBetter.com, Retrieved on 13 February 2008

[edit] See also

[edit] External links

Languages