Dependency Inversion Principle
The Dependency Inversion Principle states “High-level modules should not depend on low-level modules. Both should depend on abstractions.”
In simpler terms this principle helps you reduce the coupling between high-level and low-level modules by introducing a layer of abstraction, typically in the form of interfaces or abstract classes. By doing so, it promotes flexibility, maintainability, and scalability in software design, allowing for easier modifications and extensions without affecting other parts of the system.
I like to use the power strip analogy. The power strip would be the interface in this situation. The appliance you plug into the interface doesn’t care what it is plugging into, as long as its getting power at the end of the day. The wires in the wall don’t care what it is powering. The power strip is a single abstraction with the rules of implementation for both the high level (wires in the wall) and low level (the appliances you plug in).
The power strip does not care if the electricity is being generated by nuclear power, solar power, or coal power. It just cares that there is a constant current coming in. It also does not care if a blender blends, or a toaster toasts.
It will send electricity regardless, the details can be left to each individual device.