Skip to main content

SOLID

SOLID is an acronym for five software design principles that were introduced by Robert C. Martin (also known as Uncle Bob) in the early 2000s. The five principles are:

Single Responsibility Principle (SRP): A class should have only one reason to change. Open-Closed Principle (OCP): Software entities should be open for extension, but closed for modification. Liskov Substitution Principle (LSP): Objects of a superclass should be replaceable with objects of its subclasses without breaking the application. Interface Segregation Principle (ISP): A client should not be forced to implement an interface that it does not use. Dependency Inversion Principle (DIP): High-level modules should not depend on low-level modules. Both should depend on abstractions. The SOLID principles are guidelines for designing software systems that are easy to maintain, extend, and refactor. By following these principles, developers can create code that is more flexible, scalable, and resilient to changes in requirements.

The Single Responsibility Principle (SRP) is about creating classes and modules that have a single responsibility. This means that a class should only have one reason to change, which makes it easier to understand and maintain.

The Open-Closed Principle (OCP) is about designing software systems that can be extended without modifying their source code. This is achieved by using abstractions and interfaces that allow new functionality to be added without breaking existing code.

The Liskov Substitution Principle (LSP) is about creating objects that can be replaced by objects of their subtypes without affecting the correctness of the system. This principle ensures that the behavior of a superclass is preserved when it is extended by a subclass.

The Interface Segregation Principle (ISP) is about creating interfaces that are specific to the needs of the client. This principle ensures that clients are not forced to implement methods they don't need, which makes the code more maintainable and easier to test.

The Dependency Inversion Principle (DIP) is about designing software systems that depend on abstractions rather than concrete implementations. This principle allows for greater flexibility and easier testing, as the system can be composed of interchangeable components.