cln.co/
DIP
DIPDependency Inversion Principle

"Depend upon abstractions, not upon concretions." - Robert C. Martin

Key Takeaways
  • Rely on general concepts rather than specifics.
  • Separate core program logic from detailed components.
  • Ensure small component changes don't disrupt core logic.

Example

A high-level class defines an interface and the low-level classes implement the interface, providing specific functionality.

DIP visual

Description

Software components should rely on abstract interfaces rather than concrete implementations.

This principle acts as a key mechanism for achieving flexible and robust object-oriented architectures by ensuring that high-level modules, which contain business logic and policies, are not directly dependent on low-level modules with specific implementations.

By depending on abstractions, the code is less susceptible to changes and can be more easily extended or modified without altering the existing high-level modules.

You might also like:
ADP
APO
BSR
CCP
CoI
CQS
CRP
DIP
DRY
EUHM
EWV
FF
FTSE
GRASP
HC
HLYW
IH
IoC
IOSP
ISP
KISS
LC
LoD
LOLA
LSP
OCP
POLP
POLS
PoMO
REP
RoT
RTFM
SAP
SDB
SDP
SLA
SoC
SOLDIER
SOLID
SPOT
SRP
TdA
WET
YAGNI
ZOI