SOLID OOP development – the dependency inversion principle
In this guide, we'll walk through the final element of the SOLID development pattern, the Dependency Inversion Principle (DIP).
If you have had a difficult time understanding some of the other SOLID guides, you'll be happy to know that this principle is probably the most straightforward.
The DIP in the real world
The reason why I think that the DIP is easy to understand is that it relates to a real-world pattern. Before we jump into the code, we'll look at how a large company is structured.
Let's imagine that you're the CEO of Coca-Cola. As the CEO of a multibillion dollar company, you will have a number of responsibilities. Some of these tasks might be as follows:
- Managing shareholders
- Making strategic acquisitions
- Deciding which markets to enter
- Also, a number of other high-level decisions
Now let's look at what you wouldn't do as the CEO of Coca-Cola:
- Drive a truck and make product deliveries
- Pick SEO keywords for the corporate website
- Work...