The SOLID principles are five design principles for writing maintainable and scalable software. They were introduced by Robert C. Martin and are widely used in object-oriented programming. The SOLID principles are:
Single Responsibility Principle (SRP)
Name
Description
Syntax
Example
SRP
A class should have only one reason to change.
class Car { … }
A Car class should have only the responsibilities related to the car, such as driving and fueling, but not the responsibilities of a parking lot, such as managing parking spots.
Open/Closed Principle (OCP)
Name
Description
Syntax
Example
OCP
Software entities should be open for extension but closed for modification.