The dependency inversion principle states the following:
- High-level modules should not depend on low-level modules. Both should depend on abstractions (that is, interfaces)
- Abstractions should not depend on details. Details (such as concrete implementations) should depend on abstractions
The first point may remind you of the LoD. It is largely talking about the same concept: the separation of high-level from low-level.
Our abstractions should be separated (decoupled) in such a way that we can easily change low-level implementation details at a later date without having to refactor all of our code. The dependency inversion principle, in its second point, suggests that we do this via intermediary abstractions ...