SOLID Principles
Five fundamental design principles for creating maintainable, scalable, and flexible object-oriented software systems.
Also known as: SOLID, SOLID Design Principles
Category: Principles
Tags: software-development, design-patterns, object-oriented, principles, architecture, clean-code, maintainability
Explanation
SOLID is an acronym representing five core principles of object-oriented programming and design, introduced by Robert C. Martin (Uncle Bob). These principles guide developers in creating software that is easy to maintain, extend, and refactor.
**Single Responsibility Principle (SRP)**: A class should have only one reason to change, meaning it should have only one job or responsibility. This keeps classes focused and makes them easier to understand, test, and maintain.
**Open-Closed Principle (OCP)**: Software entities (classes, modules, functions) should be open for extension but closed for modification. You should be able to add new functionality without changing existing code, typically achieved through abstraction and polymorphism.
**Liskov Substitution Principle (LSP)**: Objects of a superclass should be replaceable with objects of its subclasses without affecting the correctness of the program. Subtypes must be substitutable for their base types without altering desirable properties.
**Interface Segregation Principle (ISP)**: No client should be forced to depend on methods it does not use. Instead of one large interface, many smaller, specific interfaces are preferable, allowing clients to only know about the methods that are relevant to them.
**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 promotes loose coupling and makes systems more flexible.
Together, these principles help developers avoid code smells, reduce technical debt, and build systems that can evolve gracefully over time. They are foundational to many modern software architecture patterns and practices.
Related Concepts
← Back to all concepts