SOLID - Os princípios que se você não souber, você fica para trás
Tech1 of 2
Kon: The Single Responsibility Principle
The Single Responsibility Principle (SRP) dictates that a class should have only one reason to change. The presenter contrasts a problematic 'Order' class handling business logic, persistence, and email communication with a refactored approach where each concern is separated into distinct classes (Order, EmailService, OrderRepository). This separation reduces coupling and increases cohesion, making the system more predictable and easier to maintain.
Interface Segregation: Small, Focused Interfaces
The Interface Segregation Principle (ISP) advocates for creating small, specific interfaces rather than large, general ones. The video uses a 'Worker' interface with 'eat' and 'work' methods. A robot implementing this is forced to have an 'eat' method, which is nonsensical. By splitting into 'Worker' (work) and 'Eatable' (eat) interfaces, classes like 'Human' can implement both, while 'Robot' only implements 'Worker', avoiding unnecessary dependencies and keeping code clean.
