The dependency inversion principle states that higher level modules should not depend on low level modules ~ both higher and lower level modules should depend on abstractions. Abstractions should not depend on details.
Details should depend upon abstractions.
Dependency Inversion is one of the most powerful design patterns out there due to it allowing us to invert our dependency tree, but out of all of the SOLID Principles ~ Dependency Inversions is probably the most complicated...at first glance.
1. Higher level modules: Accept Abstraction As Parameter Or Argument
2. Lower level modules: Implement Abstraction's behavior
3. Higher level modules depend on abstract by accepting them as arguments while lower level modules depend on abstractions by implementing the required behavior demanded by the interface.
The lower level module is responsible for implementing the required behavior.
Dependency Inversion. #ObjectOrientedDesignPatterns
~~~~~~~~~~~~~~~~~~~~~~
Clean Code Studio ~ Simplify!
Clean Code Clean Life
0 Comments