The Interface Segregation Principle (ISP) is the SOLID design principle, attributed to Robert C. Martin, that clients should not be forced to depend on interfaces they do not use. It prefers many specific, client-specific interfaces over one general-purpose interface. This spares classes from implementing methods they do not need and keeps changes to an interface from affecting clients that never call the changed methods.
SOLID-Interface Segregation Principle
Details
- Full Name
-
SOLID Interface Segregation Principle (ISP)
Intent:
Clients should not be forced to depend on interfaces they do not use. Prefer many specific interfaces over one general-purpose interface.
When to Use:
-
Classes implement interface methods they don’t need (empty or throwing)
-
Changes to an interface affect clients that don’t use the changed methods
-
Fat interfaces with many methods serving different client groups
Prompt Example:
"Refactore dieses Interface nach dem SOLID-Interface Segregation Principle in kleinere, clientspezifische Interfaces."
Related Anchors:
-
SOLID Principles (Umbrella)