A class should have just one reason to change, meaning it should be responsible for a single part of the system's functionality. Keeping concerns separated reduces complexity, makes classes easier to understand, and prevents unintended side effects when one responsibility changes.
Examples:
- An
Employeeclass that both manages employee data and prints timesheet reports has two reasons to change. Moving the report-printing logic into a dedicatedTimesheetReportclass ensures that a change to report format never risks breaking employee-data handling.
Synonyms: srp