Skip to content
Preptima
mediumConceptDesignMidSenior

What is the dependency inversion principle, and what exactly is being inverted?

3 min readUpdated 2026-08-15

Answer

Short answer

High-level policy should not depend on low-level detail; both should depend on an abstraction. What inverts is ownership of the interface - it belongs to the module that consumes it, not to the one that implements it, which is what reverses the direction of the source dependency.

Was this answer helpful?

Likely follow-ups

  • You have one implementation and no plans for a second. Is the interface still justified?
  • Where should the interface file physically live, and why does that matter?
  • How is this different from dependency injection?
  • Your repository interface returns a database-specific cursor type. What has gone wrong?

Related questions

Related Topics