User Tools

Site Tools


principles:dependency_inversion_principle

This is an old revision of the document!


Dependency Inversion Principle (DIP)

Variants and Alternative Names

Context

Principle Statement

Depend on abstractions.1)

Description

Rationale

Strategies

  • Apply the Dependency Inversion Pattern
  • Apply other forms of dependency inversion
  • Have an interface type for every class
  • Declare only interface types so that an object variable generally has an interface as static type and a concrete class as dynamic type

Caveats

It is normally not helpful to apply DIP to value objects.

Furthermore note that applying dependency inversion pattern (see strategies) introduces an abstraction. FIXME explain Super-A vs. ReqByB

See section contrary principles.

Origin

Evidence

Relations to Other Principles

Generalizations

  • Low Coupling (LC): LC aims at reducing the dependencies to other modules. One way to do so is to only depend on abstractions. DIP is about this aspect.

Specializations

Contrary Principles

  • More Is More Complex (MIMC): DIP demands introducing abstractions, especially abstract classes or interfaces.

Complementary Principles

  • Model Principle (MP): DIP demands having abstractions. MP tells how these abstractions can look like.

Principle Collections

OOD Principle Language
General Principles
ML KISS MIMC DRY GP RoE
Modularization Principles
MP HC ECV
Module Communication Principles
TdA/IE LC DIP
Interface Design Principles
EUHM PLS UP
Internal Module Design Principles
IH/E IAP LSP PSU

Examples

Description Status

Further Reading

1)
Robert C. Martin: Agile Software Development, Principles, Patterns, and Practices, p. 129
principles/dependency_inversion_principle.1363596278.txt.gz · Last modified: 2013-05-20 12:46 (external edit)