ISP vs SRP — interface segregation vs single responsibility
Fast recall
Quick revision
Core answer
Interview-ready guide
Interview answer
SRP and ISP solve related but different problems. SRP asks whether a class or module owns one cohesive responsibility and has one primary reason to change. ISP asks whether a client-facing contract contains only the operations that consumer needs.
For example, a cohesive administration service may still expose a broad interface to a read-only report, which is an ISP problem. In the other direction, one large implementation can satisfy several small interfaces and still mix unrelated policies internally, which is an SRP problem.
The remedies follow the diagnosis: separate independently changing responsibilities for SRP, and provide capability-focused contracts for ISP. One refactor may improve both, but interface size and class responsibility are not the same measurement.
ISP vs SRP — interface segregation vs single responsibility
Direct Answer
SRP asks whether a class or module has one primary reason to change. ISP asks whether a client depends on a contract containing operations it does not use. One concerns responsibility and change ownership; the other concerns the shape of client-facing capabilities. A large service and a fat interface often appear together, but either violation can exist alone.
Code Example
// ISP: the report client sees only the capability it uses.
interface InvoiceReader {
Invoice find(long id);
}
// SRP: formatting and delivery change for different reasons.
final class InvoiceFormatter {
String format(Invoice invoice) { return invoice.toString(); }
}
final class InvoiceMailer {
void send(String body, String address) { /* SMTP adapter */ }
}
The focused reader contract addresses ISP. Separating formatting from delivery addresses SRP. Neither improvement automatically proves the other.
Common Mistakes & Pitfalls
- Calling SRP the class version of ISP: responsibility and client dependency are different questions.
- Assuming small interfaces prove SRP: one implementation can still own unrelated policies.
- Assuming a cohesive class has a good client API: a narrow client may still receive too many operations.
- Applying both mechanically: use actual change reasons and usage patterns.
Check your understanding
Answer these without looking back at the article.
- Can you have an ISP violation without an SRP violation?
- Which SOLID principle is hardest to apply in practice?
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.