mediumConceptDesignMidSeniorStaff
Give me a real single-responsibility violation you have seen, and how would you refactor it?
5 min readUpdated 2026-08-15
Answer
Short answer
A class violates SRP when it has more than one reason to change, not when it has more than one method; the refactor is to split along the axes that have independently churned, such as pricing rules, persistence, and presentation, and to stop splitting once each piece has its own requester.
Was this answer helpful?
Likely follow-ups
- How would you decide between an interface and a plain function for the extracted pricing rule?
- What would make you leave a class that violates SRP exactly as it is?
- How does this refactor change what you can unit test without a database?
- Where does the open-closed principle start to conflict with keeping the class count low?
Related questions
- This interface has twelve methods and every implementation throws UnsupportedOperationException for four of them. What went wrong, and how would you fix it?mediumAlso on solid and refactoring5 min
- When would you use the observer pattern, and what goes wrong with it at scale?mediumAlso on coupling4 min
- When would you use the strategy pattern instead of inheritance?mediumAlso on refactoring5 min
- Service A needs something from service B. When should that be a synchronous call and when should it be an event?mediumAlso on coupling4 min