Site Tools


swe:solid

Table of Contents

SOLID

SOLID is five object-oriented design principles: Single Responsibility, Open/Closed, Liskov substitution principle, Interface Segregation, Dependency Inversion. They make code more understandable, maintainable, and extensible.

A class with multiple reasons to change is harder to modify when each reason occurs independently. Adding new behaviour requires editing existing code, creating risk of regression. Interfaces and abstractions allow new behaviour without modifying old code. Clients depend on huge interfaces that include methods they do not use, creating coupling.

Apply these principles to make dependencies explicit, allow substituting implementations, and keep each class focused. The tradeoff is complexity: small programs or functional code does not benefit as much, and strict adherence can produce over-engineered designs.

swe/solid.md · Last modified: by 127.0.0.1