wiki / concepts / dependency-inversion-principle

Dependency Inversion Principle

updated 2026-08-25 principle

Dependency Inversion Principle

A design principle that enables clean architecture’s dependency rule to work in practice by using dynamic polymorphism to create source code dependencies that oppose the flow of control. This allows necessary communication across architectural boundaries while maintaining inward-pointing dependencies.

Mechanism

When control must flow outward (violating the dependency rule):

  1. Inner layer defines interface — specifies the contract it needs
  2. Outer layer implements interface — provides concrete implementation
  3. Source dependency points inward — satisfies the dependency rule
  4. Control flows outward — achieves necessary functionality

Practical Application

Example: Use case needs to call presenter

  • Use case calls interface (Use Case Output Port) in its own layer
  • Presenter implements that interface in the outer layer
  • Source code dependency: Presenter → Use Case Output Port (inward)
  • Control flow: Use Case → Presenter (outward)

Role in Clean Architecture

The dependency inversion principle is the key mechanism that allows clean architecture to maintain the dependency rule while enabling all necessary communication between layers. Without this principle, the architectural constraints would be impossible to satisfy in practice.

[source: uncle-bob-clean-architecture-2012]

Evidence — verified primary sources
uncle-bob-clean-architecture-2012 https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html
ingested 2026-08-25
sha256:b99ae450b598…