Skip to content
Preptima
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