SOLID PrinciplesInterface Segregation PrincipleEasy⏱️ ~2 min

What is the Interface Segregation Principle (ISP)?

Definition
Interface Segregation Principle (ISP) states that clients should not be forced to depend on interfaces they do not use. Instead of one fat interface, prefer multiple smaller, focused interfaces.

ISP is the fourth principle in SOLID. It addresses the problem of bloated interfaces that force implementing classes to provide empty or meaningless implementations for methods they do not need.

Core Problem It Solves

When an interface grows too large with many methods, classes that implement it must provide all methods even if they only need a subset. This creates several issues:

First, implementing classes carry unnecessary baggage with stub methods that throw exceptions or do nothing.

Second, changes to unused methods still require recompilation of all implementing classes.

Third, clients that depend on the interface see methods they cannot or should not call, violating the Principle of Least Surprise.

The Solution

Split large interfaces into smaller, role-specific interfaces. Each interface represents a cohesive set of behaviors. Implementing classes choose only the interfaces relevant to their responsibilities.

Interview Tip: Always explain ISP in terms of client perspective, not just implementer perspective. The principle protects clients from seeing methods they should not call.
💡 Key Takeaways
Clients should not depend on interfaces they do not use
Split fat interfaces into multiple focused interfaces
Each interface should represent one cohesive role or capability
Implementing classes implement only interfaces they actually need
Protects clients from coupling to irrelevant methods
📌 Examples
1A Robot class should not implement an Eat interface meant for animals
2A PaymentProcessor should not implement scheduling methods if it only processes payments
← Back to Interface Segregation Principle Overview
What is the Interface Segregation Principle (ISP)? | Interface Segregation Principle - System Overflow