Bird
Raised Fist0

A developer claims that applying the Interface Segregation Principle (ISP) means creating an interface for every single method to avoid any unused methods. What is the flaw in this reasoning?

medium🐞 Bug Identification Q7 of Q15
OOP & Design Patterns - Interface Segregation & Dependency Inversion - Fat Interfaces & IoC
A developer claims that applying the Interface Segregation Principle (ISP) means creating an interface for every single method to avoid any unused methods. What is the flaw in this reasoning?
AISP mandates that clients implement all interfaces regardless of usage.
BCreating too many tiny interfaces can lead to excessive complexity and harder maintenance.
CISP requires combining all methods into one interface to simplify dependencies.
DISP only applies to concrete classes, not interfaces.
Step-by-Step Solution
Solution:
  1. Step 1: Understand ISP balance

    ISP encourages splitting interfaces to avoid forcing clients to depend on unused methods, but not to the extreme of one method per interface.
  2. Step 2: Analyze options

    Creating too many tiny interfaces can lead to excessive complexity and harder maintenance correctly identifies that too many tiny interfaces increase complexity and maintenance burden. ISP requires combining all methods into one interface to simplify dependencies is the opposite of ISP. ISP mandates that clients implement all interfaces regardless of usage is false; ISP avoids forcing clients to implement unused interfaces. ISP only applies to concrete classes, not interfaces is incorrect; ISP applies to interface design.
  3. Final Answer:

    Option B -> Option B
  4. Quick Check:

    Excessive interface splitting -> complexity [OK]
Quick Trick: ISP balances interface size; too many interfaces hurt [OK]
Common Mistakes:
MISTAKES
  • Thinking ISP means one method per interface
  • Believing ISP combines all methods
  • Misunderstanding ISP scope
Trap Explanation:
PITFALL
  • Candidates often overapply ISP, creating excessive interfaces, missing the balance needed.
Interviewer Note:
CONTEXT
  • Tests nuanced understanding of ISP application and its limits.
Master "Interface Segregation & Dependency Inversion - Fat Interfaces & IoC" in OOP & Design Patterns

2 interactive learning modes - each teaches the same concept differently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More OOP & Design Patterns Quizzes