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

Interface Segregation Principle

Code Quality Intermediate
debt(d7/e5/b5/t5)
d7 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'only careful code review or runtime testing' (d7). The detection_hints indicate automated detection is 'no' even though phpstan and psalm are listed — these tools can flag structural heuristics like interfaces with 10+ methods or classes throwing UnsupportedOperationException on stubs, but they cannot reliably detect ISP violations as a matter of design intent without manual review. Code review is the primary mechanism for catching fat interfaces and no-op stubs.

e5 Effort Remediation debt — work required to fix once spotted

Closest to 'touches multiple files / significant refactor in one component' (e5). The quick_fix says to split fat interfaces into small focused ones, but this is not a one-liner — it requires identifying natural capability boundaries, creating new interface files, updating all implementing classes, and updating all type hints referencing the old interface. The common_mistakes note that adding methods to existing interfaces 'breaks all implementors,' confirming multi-file impact.

b5 Burden Structural debt — long-term weight of choosing wrong

Closest to 'persistent productivity tax' (b5). ISP violations apply across web, cli, and queue-worker contexts per applies_to. Fat interfaces force every implementor to stub unused methods, and every new feature added to the fat interface ripples to all implementors. This creates a sustained productivity drag across multiple work streams but does not quite reach the level of shaping the entire system's architecture (b7).

t5 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'notable trap' (t5). The misconception field explicitly states that developers believe 'one large interface is simpler to manage than many small ones,' which is a well-documented gotcha that most OOP developers eventually learn. The confusion between ISP and SRP (noted in common_mistakes) adds a secondary cognitive trap. This is a documented pitfall but not one that contradicts how similar concepts work in other languages — it's an intermediate-level design principle trap.

About DEBT scoring →

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 63
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings T 0 pings W 2 pings T 1 ping F 0 pings S 1 ping S 0 pings M 0 pings T 0 pings W 0 pings T 1 ping F 2 pings S 2 pings S 2 pings M 1 ping T 1 ping W 0 pings T 0 pings F 1 ping S 1 ping S 0 pings M 0 pings T 0 pings W 2 pings T 0 pings F 0 pings S 1 ping S 0 pings M 0 pings T 0 pings W
No pings yet today
No pings yesterday
Perplexity 9 Amazonbot 9 Ahrefs 7 Scrapy 7 Google 6 SEMrush 4 Unknown AI 2 ChatGPT 2 Claude 2 Majestic 1 Meta AI 1 Sogou 1 Qwen 1 PetalBot 1
crawler 49 crawler_json 4
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