Madara
33.8K posts



Would you buy this chair? Prompt 👇









🧵 Day 10/30 — #LLD ISP (Interface Segregation Principle) 👉 “Clients should not be forced to depend on methods they don’t use” In simple terms: → Don’t create fat interfaces → Create small, focused ones --- Why this matters 👇 When ISP is violated: → Classes implement unused methods → Leads to empty / dummy implementations → Increases confusion → Makes code harder to maintain --- Classic example 👇 ❌ Bad design One interface: Worker → work() → eat() Now a Robot implements it 🤖 → work() ✅ → eat()? ❌ (doesn’t make sense) Forced implementation = bad design --- ✅ Better design Split interfaces: → Workable → work() → Eatable → eat() Now: → Human → implements both → Robot → implements only work() Clean. Logical. Flexible. --- 💡 Key idea: Interfaces should be: → Small → Specific → Role-based Not “one-size-fits-all” --- ⚠️ Tradeoffs: → More interfaces → Slightly more design effort But… → Better flexibility → Easier testing → Cleaner architecture --- 🔥 Rule: If a class is implementing methods it doesn’t need → Your interface is too big --- Where this shows up 👇 → Payment systems (different capabilities) → Notification services (SMS vs Email) → API design (modular endpoints) --- Would you: A) One big interface for everything B) Multiple small focused interfaces What would you choose and why? 👇






























