What is Dependency Inversion Principle in SOLID Design Principles of Object Oriented Programming
- If you are from spring framework don’t confuse this with the dependency injection or IOC.
- Higher level module shouldn’t be depending upon the lower level module, It must depend on the abstraction which means you should program to an interface but not an implementation.
- This helps to build a de-coupled application which has minimal integration issues and dependency issues.
In this simpler terms dependency inversion principle says that classes should only deal with the abstract part which is an interface but not with the concrete implementation.
The idea is that we isolate our class behind a boundary formed by the abstractions it depends on. If all the details behind those abstractions change, then our class is still safe. This helps keep coupling low and makes our design easier to change. DIP also offers us to test things in isolation, details like database are plugins to our system.