wiki / concepts / dependency-inversion-principle
Dependency Inversion Principle
Machine ingest — raw context
loading…
~… tokensappend .md to any wiki URL for this view
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):
- Inner layer defines interface — specifies the contract it needs
- Outer layer implements interface — provides concrete implementation
- Source dependency points inward — satisfies the dependency rule
- 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.
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… |
Graph context
Referenced by (3)
Clean Architectureto maintain the dependency rule while allowing necessary data flow. Interfaces in inner circles are implemented by outer circles, using dynaDependency Ruleresolves the contradiction:Model Provider Abstractionapplied to LLM infrastructure: the application depends on an abstraction it owns, not on a vendor SDK. It also de-risks context-rot economic