Bird
Raised Fist0

If the interface is split into two smaller interfaces following ISP, what is the expected effect on the client class's dependency?

easy🧠🧾 Concept Trace Q3 of Q15
OOP & Design Patterns - Interface Segregation & Dependency Inversion - Fat Interfaces & IoC
A client class depends on an interface with five methods, but only uses two of them. If the interface is split into two smaller interfaces following ISP, what is the expected effect on the client class's dependency?
AThe client's dependency remains unchanged because interfaces are just abstractions.
BThe client must implement both smaller interfaces regardless of usage.
CThe client will have to depend on all smaller interfaces to maintain compatibility.
DThe client now depends only on the interface with the two methods it uses.
Step-by-Step Solution
Solution:
  1. Step 1: Understand ISP effect

    ISP encourages splitting fat interfaces so clients depend only on methods they use.
  2. Step 2: Analyze options

    The client now depends only on the interface with the two methods it uses correctly states the client depends only on the smaller interface with the two used methods. The client must implement both smaller interfaces regardless of usage is false; clients implement only interfaces they need. The client will have to depend on all smaller interfaces to maintain compatibility is incorrect; ISP avoids forcing clients to depend on all interfaces. The client's dependency remains unchanged because interfaces are just abstractions ignores the practical effect of interface segregation.
  3. Final Answer:

    Option D -> Option D
  4. Quick Check:

    ISP reduces client dependencies to used methods only [OK]
Quick Trick: ISP splits interfaces so clients depend only on needed methods [OK]
Common Mistakes:
MISTAKES
  • Believing clients must implement all interfaces after splitting
  • Thinking interface splitting does not affect dependencies
  • Confusing interface abstraction with dependency scope
Trap Explanation:
PITFALL
  • Candidates often think splitting interfaces forces clients to implement more interfaces or that dependencies remain unchanged.
Interviewer Note:
CONTEXT
  • Checks understanding of ISP's impact on client dependencies.
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