# SOLID Principles Five design principles that make software systems easier to understand, maintain, and extend. Introduced by Robert C. Martin (Uncle Bob). The acronym was coined by Michael Feathers. ## The five principles **S - Single Responsibility Principle (SRP)**: a module should have one, and only one, reason to change. Closely related to [[Atomicity]]; one unit of code owns one concern. When a class does two things, changes to one concern risk breaking the other. **O - Open/Closed Principle (OCP)**: software entities should be open for extension but closed for modification. Add new behavior by adding new code, not by changing existing code. Extension points, plugins, and configuration are implementations of this. **L - Liskov Substitution Principle (LSP)**: subtypes must be substitutable for their base types without altering program correctness. If code works with a base type, it must also work with any derived type. Violations surface as unexpected behavior when swapping implementations. **I - Interface Segregation Principle (ISP)**: clients should not be forced to depend on interfaces they do not use. Prefer many small, focused interfaces over one large general-purpose one. Reduces coupling and prevents bloated dependencies. **D - Dependency Inversion Principle (DIP)**: high-level modules should not depend on low-level modules; both should depend on abstractions. Abstractions should not depend on details; details should depend on abstractions. This enables swapping implementations without changing consumers. ## Why they matter These principles reduce the cost of change. Software that violates them becomes rigid (hard to change), fragile (changes cause unexpected breakage), and immobile (hard to reuse). SOLID code is easier to test, extend, and reason about. ## Beyond object-oriented code SOLID was formulated for OOP, but the underlying ideas apply broadly: - Microservices (each service = SRP) - API design (ISP = focused endpoints) - Plugin systems (OCP = extension without modification) - AI skills and agents (see [[Software Design Patterns for AI Skills and Agents]]) The principles describe properties of well-designed systems, not just well-designed classes. ## References - Robert C. Martin, "Design Principles and Design Patterns" (2000) - Robert C. Martin, "Clean Architecture" (2017) ## Related - [[Atomicity]] - [[Separation of Concerns]] - [[Loose Coupling]] - [[High Cohesion]] - [[Composition over Inheritance]] - [[Don't Repeat Yourself (DRY) principle]] - [[Keep It Simple Stupid (KISS)]] - [[You Aren't Gonna Need It (YAGNI)]] - [[Design by Contract]] - [[Software Design Patterns for AI Skills and Agents]]