-
Notifications
You must be signed in to change notification settings - Fork 0
The SOLID Design Principles π¨βπ
Lyes S edited this page Jun 24, 2022
·
9 revisions
Table Of Contents
- Single Responsibility Principle
- Open/Closed Design Principle
- Liskov Substitution Principle
- Interface Segregation Principle
- Dependency Inversion Principle
- Each class should be responsible for a single part or functionality of the system.
public class Entity {
public void printTooMuchDetails() {}
public void calculateEstimate() {}
public void addEntityToDatabase() {}
}
The Entity class has three separate responsibilities: reporting, calculation, and database. This violate the SRP principle.
A better approach would be to separate the above class into three classes with separate responsibilities.
Β© 2024 | Lyes Sefiane All Rights Reserved | CC BY-NC-ND 4.0