🏗️ SOLID Principles
Beginner
What does the Interface Segregation Principle (ISP) mean?
Answer
The Interface Segregation Principle states that clients should not be forced to depend on methods they do not use. Instead of one large, general-purpose interface, you should create smaller, role-specific interfaces. For example, a Worker interface with methods work(), eat(), and sleep() forces a RobotWorker to implement eat() and sleep() which are irrelevant to it. Better design: separate Workable, Eatable, and Sleepable interfaces. ISP keeps interfaces cohesive and prevents classes from being burdened with methods they don't need, reducing coupling and making implementations more focused.
Previous
What does the Liskov Substitution Principle (LSP) mean?
Next
What does the Dependency Inversion Principle (DIP) mean?