SOLID is an acronym for five design principles, coined by the American computer scientist and instructor Robert C. Martin. The goal of these principles is to assist developers in creating a understandable, flexible, and maintainable software or system. So let’s dive in to see what kind of advantage these principles can offer.
S – Single Responsibility Principle (SRP):
“A class should have only one reason to change”.
In other words, your class or method should have only one responsibility.
Example:

As you can see, in this example, if you follow the SRP then your codebase will be longer, but there are also benefits to it:
+ Because each class handles only one responsibility, it’s easier for other member in your project to follow, modify and extend upon.
+ Improve the Unit testing phase because classes are smaller and more focused.
+ Your code can be reuse in other parts of the system, or even in different projects.
O – Open/Closed Principle (OCP):
“Software entities should be open for extension but closed for modification”.
It means you should be able to add new functionality to a system without changing existing code.
Example:

In this example, if you want to add a new animal sound, you can create a new class that extends the SoundMade class and pass it into the constructor of the Animal class. This offer some benefits:
+ By not modifying the existing codes, you can minimize the risk of introducing new bugs or breaking the current state of the system.
+ The use of polymorphism and abstraction makes your system easier to accommodate changes.
L – Liskov Substitution Principle (LSP):
“Objects of a superclass should be replaceable with objects of its subclasses without affecting the correctness of the program”.
This was introduced by Barbara Liskov, a pioneer computer scientist and Turing Award winner in 1987.
Example:

By following Liskov Substitution Principle, you can:
+ Improve the reusability of your classes.
+ Reduce the risk of introducing undefined bugs to your system.
+ Maintain the consistency and predictability of your code when using polymorphism.
I – Interface Segregation Principle (ISP)
“No client should be forced to depend on interfaces it does not use”.
To be more specific, the principle suggests software developers to break down larger interfaces and methods into many smaller and more specific ones. By this, the client (classes or modules) only need to implement the methods they require.
Example:

Benefits:
+ By breaking down a fat interface into small and specific ones, your classes/modules now only need to implement the methods they need, therefore reducing unnecessary dependencies and improve code reusability.
+ Your code becomes less complex, easier for other members to modify and extend.
+ Improve Unit Testing phase since the test won’t be affected by unnecessary methods or dependencies.
D – Dependency Inversion Principle (DIP)
“High-level modules should not depend on low-level modules. Both should depend on abstractions.”
“Abstractions should not depend on details. Details should depend on abstractions”.
In other words, high-level modules (or classes) which contain your business logic, should not be relied on the lower, implementation-specific modules (or concrete classes). Instead, they should all depend on interfaces and abstract classes.
Example:

In this example, instead of your typical dependency:「High-Level --> Low-Level」, the relationship between classes becomes「High-Level --> Abstraction <-- Low-Level」. Benefits:
+ Thanks to the abstraction, your code becomes less tightly coupled, making it easier to modify and extend, without the fear of affecting the current state of the system.
+ Improve the reusability of High-level modules.
+ You can create mock implementations of Low-level modules to make Testing faster and more reliable.
A "Solid" Summary
At its core, all five principles serve a unified purpose: to effectively manage dependencies. By integrating the SOLID principles into your projects, developers can ensure that their codebase is easier to maintain, refactor, and extend upon.
But blindly following every principle without fully understanding its intent can be counterproductive, leading to the most common mistake a developer can make: over-engineering. So as a professional developer, you need to apply these principles with discernment - focusing on the most complex and critical parts of your application, rather than striving for a perfectly "SOLID" codebase.
If you're eager to take your programming skills to the next level and apply them to impactful, real-world projects, ISB VIETNAM offers an environment where Passions, Teamwork, Innovations, and continuous learning are part of our everyday work. Visit the official website now to learn more about our company services, and how you can become part of a team that values thoughtful, high-quality software engineering.