SOLID Principles
Single responsibility, Open-closed, Liskov substitution, Interface segregation, Dependency inversion.
SOLID is a mnemonic for five principles of object-oriented design and programming articulated by Robert C. Martin ('Uncle Bob') across articles in the 1990s and consolidated in subsequent works including Agile Software Development (2002) and Clean Code (2008). Single Responsibility Principle (SRP): a class should have only one reason to change, often summarized as 'one responsibility' though Martin's intended meaning is closer to 'one stakeholder driving change'. Open-Closed Principle (OCP), originally Bertrand Meyer's: software entities should be open for extension but closed for modification, achieved through abstraction and polymorphism. Liskov Substitution Principle (LSP), Barbara Liskov's 1987 contribution: subtypes must be substitutable for their base types without breaking client expectations. Interface Segregation Principle (ISP): clients should not be forced to depend on methods they do not use — prefer many specific interfaces over few general ones. Dependency Inversion Principle (DIP): high-level modules should not depend on low-level modules; both should depend on abstractions. SOLID is among the most-taught object-oriented design principles, while drawing critique for being over-applied in contexts (functional programming, simple CRUD applications) where the principles add complexity without benefit.
Core components
- Single Responsibility Principle (SRP)
- Open-Closed Principle (OCP, Meyer 1988)
- Liskov Substitution Principle (LSP, Liskov 1987)
- Interface Segregation Principle (ISP)
- Dependency Inversion Principle (DIP)
- Object-oriented design context
- Connection to design patterns (GoF) and clean code
- Foundation for Clean Architecture's dependency rule
Primary use case
Object-oriented design education and practice; code review heuristics and refactoring guidance; foundation for testable application design; widely-cited reference in software craftsmanship and clean-code communities; basis for many static analysis and code-quality rules.
Common criticisms
- Each principle has been substantially debated — SRP's 'one responsibility' is genuinely ambiguous and Martin's later 'one stakeholder' clarification is less memorable
- OCP's prescription against modification is in tension with refactoring discipline
- ISP can produce interface proliferation
- DIP can produce abstraction layers without benefit in simple applications
- SOLID as a whole is well-suited to enterprise OO but applies awkwardly to functional, scripting, and small applications
- can be cargo-culted as architectural ceremony
- Dan North's 2022 'Why Every Element of SOLID is Wrong' provided substantial critique from a senior practitioner
- the principles describe good outcomes more than they prescribe how to achieve them.
Lineage
- Siblings
- DRY, KISS, YAGNI, Clean Architecture