Evolving Software: SOLID principles as a continuum
It is actually just once principle — Decouple
SOLID principles are powerful tools for building a system with low coupling between its components. A quick recap on these principles:
- SRP: Single Responsibility Principle
- OCP: Open Closed principle
- Liskov Substitution Principle
- Interface Segregation
- Dependency Inversion
If you don’t know what these terms mean, I recommend this primer. Go check it out and then read the rest of this article.
Here, I want to talk about how all the SOLID principles are interlinked. They all apply simultaneously in any situation. Breaking one will also break multiple others. In my opinion, they should be read as a continuum, rather than a set of independent principles — one always needs some of them to achieve the other(s).
Personally, I start by saying that I don’t want to modify the existing code. Who knows how I might break it? I want to just inject my new logic into the currently running system in the specific places where I need to. So SRP is kind of my favourite principle. But all other principles come in to uphold this one.
Let’s consider the windows machine example from the primer I linked above. Here’s the class for reference.