Zuruck zum Glossar
Metriken & Architektur

SOLID Principles

Five design principles for object-oriented programming that promote maintainable, flexible, and understandable code: Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion.

Definition

SOLID is an acronym for: Single Responsibility (a class should have one reason to change), Open-Closed (open for extension, closed for modification), Liskov Substitution (subtypes must be substitutable for base types), Interface Segregation (many specific interfaces are better than one general), and Dependency Inversion (depend on abstractions, not concretions). These principles were promoted by Robert Martin.

Warum es wichtig ist

SOLID principles reduce coupling, increase cohesion, and make code easier to test, maintain, and extend. Violations often lead to fragile code where changes cascade unexpectedly. Code review tools like diffray can flag SOLID violations in architecture reviews.

Beispiel

Violating Single Responsibility: a UserService that handles authentication, database operations, and email sending. Following SOLID: separate AuthService, UserRepository, and EmailService classes.

Verwandte Begriffe

SOLIDSOLID principleswhat is SOLIDSOLID OOPsingle responsibility

Automatisieren Sie Code Review mit diffray

Multi-Agent KI-System fur Code Review. Findet automatisch Bugs, Sicherheitslucken und Architekturprobleme.