Solid Properties
Solid Properties
Colorful Examples
A Comprehensive Guide
February 9, 2025
Introduction
Software design principles help developers create maintainable, scalable, and
robust software. The SOLID principles are five key object-oriented design
principles that ensure software is easy to manage and extend.
What is SOLID?
SOLID is an acronym for:
1
1 Single Responsibility Principle (SRP)
1.1 Definition
A class should have only one reason to change, meaning it should have only
one job.
class ReportPrinter {
public :
void printReport () { /* Prints report */ }
};
2
2 Open/Closed Principle (OCP)
2.1 Definition
Software entities should be open for extension but closed for modification.
3
Why is this good? New invoice types can be added without modifying
existing code.
4
3 Liskov Substitution Principle (LSP)
3.1 Definition
A subclass should be replaceable by its base class without altering the cor-
rectness of the program.
5
public :
void move () override { /* Waddle on ground */ }
};
6
4 Interface Segregation Principle (ISP)
4.1 Definition
Clients should not be forced to depend on interfaces they do not use.