"A module should be responsible to one, and only one, actor."
The most common misunderstanding is thinking SRP means "a class should do only one thing."
The Real Definition: A class should have only one reason to change.
In software architecture, a "reason to change" corresponds to a specific group of people—an Actor—who requires that change.
"Gather together the things that change for the same reasons. Separate those things that change for different reasons."
— Robert C. Martin (Uncle Bob)
link SourceExplore the classic "God Object" violation. Hover over the methods in the code to see which "Actor" owns them.
This class has three reasons to change. If the CFO changes pay calculation rules, we edit this file. If the CTO changes the database schema, we edit this same file. This coupling risks accidental breakage (e.g., changing a shared utility function for pay calculation might break the hour report).
Finance Dept
Responsible for calculatePay(). Requires changes to tax formulas & salary logic.
Operations Dept
Responsible for reportHours(). Requires changes to report formats & compliance.
IT / DBA
Responsible for save(). Requires changes to database schemas & persistence.
Instead of one "God Class", we separate the concerns into distinct classes. Each class now has only one actor to answer to.
The current code mixes business rules, reporting logic, and database operations. Click "Refactor Code" to apply the Single Responsibility Principle.
The government changes the income tax calculation formula. In a properly refactored system, who is the actor requesting this change, and which class should be touched?
We are moving from MySQL to PostgreSQL. Which module should be modified?