1.2 KiB
1.2 KiB
SOLID Principles
The SOLID principles are five design guidelines for writing maintainable, flexible, and scalable object-oriented code. Here's a quick summary:
- Single Responsibility Principle (SRP): A class should have only one reason to change, meaning it should have a single responsibility or purpose.
- Open/Closed Principle (OCP): Classes should be open for extension (e.g., adding new functionality) but closed for modification (no need to change existing code).
- Liskov Substitution Principle (LSP): Subclasses should be substitutable for their base classes without breaking the program's behavior.
- Interface Segregation Principle (ISP): Clients should not be forced to depend on interfaces they don't use, favoring specific, small interfaces over large, general ones.
- Dependency Inversion Principle (DIP): High-level modules should not depend on low-level modules; both should depend on abstractions (e.g., interfaces), and abstractions should not depend on details.
These principles promote cleaner, more modular, and testable code.