← CodeClarityLab Home
Browse by Category
+ added · updated 7d
← Back to glossary

Interface Segregation Principle

quality Intermediate

Also Known As

ISP Interface Segregation Principle fat interface

TL;DR

Clients should not be forced to depend on interfaces they do not use — prefer many small, focused interfaces over one large one.

Explanation

The I in SOLID, ISP states that a class implementing an interface should not be forced to implement methods it doesn't use. Fat interfaces that bundle unrelated methods force implementors to provide stub implementations for irrelevant methods. The solution is to split large interfaces into smaller, cohesive ones and have classes implement only what they need. This complements the Dependency Inversion Principle — depend on the narrowest interface needed for the task.

Common Misconception

One large interface is simpler to manage than many small ones. A large interface forces implementors to stub out methods they do not use, creating misleading no-op implementations and tight coupling to functionality the implementor does not need.

Why It Matters

The Interface Segregation Principle prevents classes from being forced to implement methods they don't use — large interfaces create fake implementations and hide which capability is actually needed.

Common Mistakes

  • One large repository interface with 20 methods — every implementation must stub 15 unused ones.
  • Adding new methods to an existing interface instead of extending it — breaks all implementors.
  • Not splitting interfaces at natural capability boundaries — Readable, Writable, Listable rather than FileRepository.
  • Confusing ISP with SRP — ISP is about interface design, SRP is about class responsibility.

Code Examples

✗ Vulnerable
interface Worker {
    public function work(): void;
    public function eat(): void;   // robots don't eat!
    public function sleep(): void; // robots don't sleep!
}

class RobotWorker implements Worker {
    public function eat(): void  { throw new \Exception('Robots do not eat'); }
    public function sleep(): void { throw new \Exception('Robots do not sleep'); }
}
✓ Fixed
interface Workable  { public function work(): void; }
interface Feedable  { public function eat(): void; }
interface Restable  { public function sleep(): void; }

class HumanWorker  implements Workable, Feedable, Restable { ... }
class RobotWorker  implements Workable { ... }

Added 15 Mar 2026
Edited 22 Mar 2026
Views 33
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings W 0 pings T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W 1 ping T 0 pings F 0 pings S 0 pings S 1 ping M 0 pings T 2 pings W 2 pings T 0 pings F 2 pings S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 0 pings F 2 pings S 1 ping S 0 pings M 0 pings T 0 pings W 1 ping T
No pings yesterday
Perplexity 9 Amazonbot 7 Ahrefs 5 Unknown AI 2 Google 2 ChatGPT 2 Majestic 1 SEMrush 1
crawler 27 crawler_json 2
DEV INTEL Tools & Severity
🟡 Medium ⚙ Fix effort: Medium
⚡ Quick Fix
Split fat interfaces into small focused ones — clients should only implement what they actually use; a class implementing an interface with unused methods is a sign of violation
📦 Applies To
any web cli queue-worker
🔗 Prerequisites
🔍 Detection Hints
Interface with 10+ methods; class implementing interface throwing UnsupportedOperationException on some methods; fat PSR interface
Auto-detectable: ✗ No phpstan psalm
⚠ Related Problems
🤖 AI Agent
Confidence: Medium False Positives: High ✗ Manual fix Fix: High Context: Class Tests: Update

✓ schema.org compliant