"SOLID" is an acronym that represents a set of five design principles in object-oriented programming and software development. These principles were introduced by Robert C. Martin and are intended to guide developers in creating more maintainable, flexible, and scalable software. The SOLID principles are:
[S] Single Responsibility Principle (SRP)
"A class should have only one reason to change."
Meaning that a class should have only one responsibility or job. This principle encourages a separation of concerns and helps maintainability.
[O] Open/Closed Principle (OCP)
"Software entities (classes, modules, functions) should be open for extension but closed for modification."
This means that you should be able to add new functionality without altering existing code. This principle supports the idea of using abstractions and interfaces.
[L] Liskov Substitution Principle (LSP)
"If class A is a subtype of class B, we should be able to replace B with A without disrupting the behavior of our program."
Subtypes must be substitutable for their base types without altering the correctness of the program. In other words, objects of a superclass should be able to be replaced with objects of a subclass without affecting the functionality of the program.
[I] Interface Segregation Principle (ISP)
"A class should not be forced to implement interfaces it does not use."
This principle promotes the idea of having small, specific interfaces rather than large, general-purpose ones. Clients should not be forced to depend on interfaces they do not use.
Nenhum comentário:
Postar um comentário