SOLID Principles
Five guidelines for classes that stay easy to change, each with the smell that tells you it is being broken.
Why principles at all
Code is read and changed far more often than it is written. SOLID is a set of five guidelines, named by Robert C. Martin, that aim at one thing: a new requirement should cost a small, local change.
| Letter | Principle | One-line meaning |
|---|---|---|
| S | Single Responsibility | A class has one reason to change |
| O | Open/Closed | Open to extension, closed to modification |
| L | Liskov Substitution | A child can stand in for its parent without surprises |
| I | Interface Segregation | Many small interfaces beat one fat one |
| D | Dependency Inversion | Depend on abstractions, not concrete classes |
1 of 9