SOLID is an acronym for five key principles in object-oriented design and programming:
- Single responsibility principle [SRP]: A class should have only one reason to change.
- Open-Closed Principle [OCP]: Software entities should be open for extension but closed for modification.
- Liskov Substitution Principle [LSP]: Subtypes must be substitutable for their base types.
- Interface Segregation Principle [ISP]: Clients should not be forced to depend on interfaces they do not use.
- Dependency Inversion Principle [DIP]: High-level modules should not depend on low-level modules. Both should depend on abstractions.
These principles aim to make software designs more understandable, flexible, and maintainable.
- (SRP) Single Responsibility Principle:
- A class should only have one reason to change
- Separation of concerns — different classes handling different, independent tasks/problems
- (OCR) Open-Closed Principle:
- Classes should be open for extension but closed for modification
- (LSP) Liskov Substitution Principle:
- You should be able to substitute a base type for a subtype
- (ISP) Interface Segregation Principle:
- Don’t put too much into an interface; split it into separate interfaces
- YAGNI — You Ain’t Going to Need It
- (DIP) Dependency Inversion Principle:
- High-level modules should not depend upon low-level ones; use abstractions