What is a responsibility in SRP, how do you spot a violation, and how does ISP differ?
Short answer
A responsibility is a reason to change, tied to one actor (accounting, HR, the DBA); a class breaks SRP when several actors all need to change it. ISP: don't force a client to depend on methods it doesn't use.
3 points to say:
- Responsibility = reason to change = one actor; share a helper between two actors and a change for one breaks the other.
- Warning signs: git history changing for many reasons, low cohesion, many dependencies, vague names.
- SRP splits classes by source of change; ISP splits interfaces by what callers need.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.