SOLID is an acronym for five object-oriented design principles introduced by Robert C. Martin (Uncle Bob) that guide developers toward creating maintainable, scalable, and flexible software systems. These principles address dependency management and separation of concerns, helping to reduce coupling, increase cohesion, and make code easier to test, modify, and extend. While rooted in object-oriented programming, SOLID has proven relevant across paradigmsβfrom microservices architecture to modern TypeScript applications. Understanding when and how to apply these principles pragmatically, without over-engineering, is key to writing professional-grade code that withstands change.
What This Cheat Sheet Covers
This topic spans 13 focused tables and 78 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Core SOLID Principles
| Principle | Example | Description |
|---|---|---|
class User { login() {...} }class UserRepository { save() {...} } | β’ A class should have one and only one reason to change β’ it handles a single responsibility or job. | |
interface Shape { area(): number }class Circle implements Shape {...} | β’ Modules should be open for extension but closed for modification β’ add features via new code, not by changing existing code. | |
Rectangle r = new Square();r.setWidth(5); r.setHeight(10); | β’ Subtypes must be substitutable for their base types without altering program correctness β’ subclasses must honor parent contracts. |