SOLID Principles
Details
- Full Name
-
SOLID Object-Oriented Design Principles
Core Concepts:
- Single Responsibility Principle (SRP)
-
Each class should have one responsibility
- Open/Closed Principle (OCP)
-
Entities should be open for extension, 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)
-
Depend on abstractions, not concrete implementations
- Key Proponent
-
Robert C. Martin ("Uncle Bob")
When to Use:
-
Designing maintainable and scalable object-oriented systems
-
Refactoring legacy code to improve structure
-
Building systems where flexibility and testability are important
-
Teaching or enforcing good software design practices
Criticism:
-
Dan North, "CUPID — for joyful coding" (2022; preceded by his 2017 talk "Why Every Single Element of SOLID is Wrong") — the principles are too vague to guide decisions ("responsibility" is undefined) and optimise for a style of OO design that mainstream practice has moved past; he proposes the CUPID properties as an alternative
-
John Ousterhout, "A Philosophy of Software Design" (2018) — SRP-driven decomposition produces many shallow classes whose interfaces add more complexity than their implementations hide; he argues for fewer, deeper modules
-
The principles rest on anecdote and authority rather than empirical evidence — a recurring point in the debate around both critiques