Dependency inversion principle

Dependency inversion principle

In object-oriented programming, the dependency inversion principle refers to a specific form of decoupling where conventional dependency relationships established from high-level, policy-setting modules to low-level, dependency modules are inverted (i.e. reversed) for the purpose of rendering high-level modules independent of the low-level module implementation details. The principle states:

A. High-level modules should not depend on low-level modules. Both should depend on abstractions.
B. Abstractions should not depend upon details. Details should depend upon abstractions.

Contents

Description

In conventional application architecture, lower-level components are designed to be consumed by higher-level components which enable increasingly complex systems to be built. In this composition, higher-level components depend directly upon lower-level components to achieve some task. This dependency upon lower-level components limits the reuse opportunities of the higher-level components.

The goal of the dependency inversion principle is to decouple high-level components from low-level components such that reuse with different low-level component implementations becomes possible. This is facilitated by the separation of high-level components and low-level components into separate packages/libraries, where interfaces defining the behavior/services required by the high-level component are owned by, and exist within the high-level component's package. The implementation of the high-level component's interface by the low level component requires that the low-level component package depend upon the high-level component for compilation, thus inverting the conventional dependency relationship. Various patterns such as Plugin, Service Locator, or Dependency Injection are then employed to facilitate the run-time provisioning of the chosen low-level component implementation to the high-level component.

Applying the dependency inversion principle can also be seen as applying the Adapter pattern, i.e. the high-level class defines its own adapter interface which is the abstraction that the high-level class depends on. The adaptee implementation also depends on the adapter interface abstraction (of course, since it implements its interface) while it can be implemented by using code from within its own low-level module. The high-level has no dependency to the low-level module since it only uses the low-level indirectly through the adapter interface by invoking polymorphic methods to the interface which are implemented by the adaptee and its low-level module.

History

The dependency inversion principle was postulated by Robert C. Martin and described in several publications including the paper Object Oriented Design Quality Metrics: an analysis of dependencies[1], an article appearing in the C++ Report in May 1996 entitled The Dependency Inversion Principle[2], and the books Agile Software Development, Principles, Patterns, and Practices, and Agile Principles, Patterns, and Practices in C#.

See also

References

External links


Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Look at other dictionaries:

  • Dependency Inversion Principle — Das Dependency Inversion Principle (DIP; dt. Abhängigkeits Invertierungs Prinzip ) ist ein Prinzip beim Objektorientierten Entwurf von Software. Es beschäftigt sich mit der Abhängigkeit von Modulen. Strukturierung von Modulen nach DIP Im… …   Deutsch Wikipedia

  • Dependency Inversion Principle — …   Википедия

  • Dependency Inversion Prinzip — Das Dependency Inversion Principle (DIP; dt. Abhängigkeits Invertierungs Prinzip ) ist ein Prinzip beim Objektorientierten Entwurf von Software. Es beschäftigt sich mit der Abhängigkeit von Modulen. Strukturierung von Modulen nach DIP Im… …   Deutsch Wikipedia

  • Inversion De Contrôle — L inversion de contrôle (Inversion of Control, IoC) est un patron d architecture commun à tous les frameworks (ou cadre de développement et d exécution). Il fonctionne selon le principe que le flot d exécution d un logiciel n est plus sous le… …   Wikipédia en Français

  • Inversion de controle — Inversion de contrôle L inversion de contrôle (Inversion of Control, IoC) est un patron d architecture commun à tous les frameworks (ou cadre de développement et d exécution). Il fonctionne selon le principe que le flot d exécution d un logiciel… …   Wikipédia en Français

  • Inversion of control — In software engineering, Inversion of Control (IoC) is an abstract principle describing an aspect of some software architecture designs in which the flow of control of a system is inverted in comparison to procedural programming. In traditional… …   Wikipedia

  • Inversion of Control — Der Begriff Inversion of Control (IoC; deutsch: „Umkehrung der Steuerung“ oder „Steuerungsumkehr“) bezeichnet ein Umsetzungsparadigma, das in der objektorientierten Programmierung Anwendung findet. Dieses Paradigma beschreibt die Arbeitsweise von …   Deutsch Wikipedia

  • Hollywood Principle — In computer programming, the Hollywood Principle is stated as don t call us, we ll call you. It has applications in software engineering; see also implicit invocation for a related architectural principle. OverviewThe Hollywood principle is a… …   Wikipedia

  • Injection de dépendance — Inversion de contrôle L inversion de contrôle (Inversion of Control, IoC) est un patron d architecture commun à tous les frameworks (ou cadre de développement et d exécution). Il fonctionne selon le principe que le flot d exécution d un logiciel… …   Wikipédia en Français

  • Prinzipien Objektorientierten Designs — sind Prinzipien welche zu gutem objektorientierten Design führen sollen. Sie wurden neben anderen von Robert C. Martin, Bertrand Meyer und Barbara Liskov publiziert und propagiert. Viele Techniken der Objektorientierung wie Entwurfsmuster, Domain …   Deutsch Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”