Interface Segregation Principle
The Interface Segregation Principle is one of the five SOLID principles that guide object‑oriented design. It states that clients should not be forced to depend on interfaces they do not use…

Which design choice best follows the principle when a class provides many unrelated functionalities?
In the ATM UI example, what problem does applying the Interface Segregation Principle solve?
What is a typical consequence of "fat" interfaces on client code?
Which of the following best describes a violation of the Interface Segregation Principle?
When refactoring a class with low cohesion, which step aligns with the Interface Segregation Principle?
How does the Interface Segregation Principle help avoid "interface pollution by collection"?
Which scenario illustrates a correct application of the principle?
What is the primary design benefit of splitting a large interface into several smaller ones?
If a client class depends on an interface that includes methods for both reading and writing, but the client only reads, what refactoring does the principle suggest?
Understanding the Interface Segregation Principle (ISP)
The Interface Segregation Principle is one of the five SOLID principles that guide object‑oriented design. It states that clients should not be forced to depend on interfaces they do not use. In practice, this means designing small, cohesive interfaces rather than large, “fat” ones that bundle unrelated responsibilities.
Why ISP Matters
When a client implements or depends on methods it never calls, several problems arise:
- Unnecessary dependencies: The client becomes tightly coupled to functionality it does not need, making future changes riskier.
- Reduced cohesion: Large interfaces mix unrelated operations, violating the single‑responsibility mindset.
- Maintenance overhead: Adding or removing methods affects all clients, even those that never use those methods.
These issues are highlighted in the quiz question: “Why should a client avoid implementing methods it never calls?” The correct answer emphasizes that such methods create unnecessary dependencies and reduce cohesion.
Identifying “Fat” Interfaces
A "fat" interface contains many methods that serve different purposes. The typical consequence is that clients become tightly coupled to methods they never invoke. This tight coupling can lead to:
- Difficulty in refactoring because changes ripple through unrelated modules.
- Increased risk of bugs when a seemingly innocuous change affects a client that does not even use the altered method.
- Reduced readability and discoverability of the API.
In the quiz, the question about the consequence of fat interfaces directly points out this tight coupling.
Refactoring Toward Smaller Interfaces
When you encounter a class that provides many unrelated functionalities, the best design choice is to split the class into several smaller interfaces, each grouping related methods. This approach aligns with ISP and yields several benefits:
- Clear contracts: Each interface expresses a distinct responsibility.
- Tailored client dependencies: Clients only implement or depend on the interfaces they truly need.
- Enhanced testability: Mocking or stubbing becomes simpler because each mock only needs to cover a narrow set of methods.
The quiz reinforces this by asking which design choice best follows the principle when a class offers many unrelated functionalities—the correct answer is to split the class into several smaller interfaces.
Practical Example: ATM UI
Consider an ATM user interface that originally exposed a single interface containing methods for cash withdrawal, account inquiry, fund transfer, and bill payment. A client that only needs to check the account balance would still be forced to implement the entire interface, violating ISP.
Applying ISP solves this problem by separating cash withdrawal and account inquiry functionalities into distinct interfaces. The client can now depend on the AccountInquiry interface without being burdened by withdrawal‑related methods. This separation improves modularity and reduces the chance of accidental misuse.
Detecting Violations of ISP
A common violation occurs when a client class depends on an interface that contains methods unrelated to its purpose. For instance, a printing service that implements an interface with methods for printing, scanning, and faxing—while only printing is required—demonstrates a breach of ISP. The correct identification of such a violation is crucial for maintaining clean architecture.
Steps to Refactor Low‑Cohesion Classes
When you discover a class with low cohesion, follow these ISP‑aligned steps:
- Identify groups of methods that serve a common purpose.
- Extract each group into its own dedicated interface.
- Make the original class implement only the interfaces it truly needs, or create separate classes for each interface.
- Update client code to depend on the new, smaller interfaces.
The quiz question about refactoring a class with low cohesion points to the correct step: identify method groups and extract them into dedicated interfaces.
Preventing Interface Pollution by Collection
"Interface pollution by collection" refers to the situation where a single interface becomes a catch‑all for many unrelated methods, forcing every client to import the entire collection. ISP combats this by ensuring that each client receives a tailored set of methods it actually needs. This targeted approach keeps APIs lean and encourages better separation of concerns.
Real‑World Scenario: Media Player Library
A well‑known illustration of ISP in action is a media player library that provides separate interfaces for audio playback and video playback. A client that only needs audio functionality implements the AudioPlayer interface, ignoring video‑related methods. This scenario exemplifies a correct application of ISP, as highlighted in the quiz.
Key Takeaways
- Design interfaces that are cohesive and purpose‑specific.
- Avoid forcing clients to implement or depend on methods they never use.
- Refactor "fat" interfaces by extracting smaller, related groups of methods.
- Apply ISP to reduce coupling, improve maintainability, and enhance testability.
Further Reading and SEO Keywords
To deepen your understanding of the Interface Segregation Principle, explore resources that cover SOLID principles, interface design patterns, and software architecture best practices. Incorporating keywords such as "interface segregation principle tutorial", "how to avoid fat interfaces", and "ISP refactoring examples" can help you find high‑quality articles and tutorials.
