Posts

Showing posts with the label programming

Dependency Inversion Principle (DIP) Explained

Image
Dependency Inversion Principle stats : A. High-level modules should not depend on low-level modules. Both should depend on abstractions. B. Abstractions should not depend on details. Details should depend on abstractions. Simply, Depend on Abstractions and not concretes.  This principle aims at reducing the coupling between different pieces of code. Why this principle ? Making change in highly coupled code is a risky task.  The same can be simplified by making high level abstraction of your low level details.  High level abstraction can be achieved by creating interface .  Abstract concepts like logging, caching by creating interface, so even if change happens in any of these concepts, the actual logical code will be unaffected by these changes. This will be simplified by following example : Consider we have a service which does some logical operations by getting data from FTP. We also cache and log the FTP data which you receive. In const...