Dezign Patterns

Interface Segregation Principle (ISP)

📜 Definition : Clients should not be forced to depend on interfaces they do not use.
🎯 Intent : Split large interfaces into smaller, more specific ones, to avoid Unsupported operations in interface implementations.
✅ Good version:

interface Workable {
    void work();
}

interface Eatable {
    void eat();
}

class Robot implements Workable {}
class Human implements Workable, Eatable {}

❌ Interface Segregation Principle Violation Example

🧠 General Rule of Thumb:
Clients should not be forced to depend on interfaces they do not use, if it does it's probably violating ISP. 👀


 interface Worker {
     void work();
     void eat();
 }

 class Robot implements Worker {
     public void work() {}
     public void eat() {} // Doesn't make sense — robots don't eat!
 }