The Single Responsibility Principle says a class should…
Options
- Have only one method
- Have only one reason to change (Correct option)
- Be used by only one other class
- Never inherit
Answer
Have only one reason to change
Why
SRP (the S in SOLID) means a class should do one job, so only one kind of change request should ever force you to edit it.
Example: a class that calculates an invoice AND saves it to the database AND sends the email changes when tax rules change, when the database changes and when the email template changes. Split it into three classes, each with one job.
Remember
One class, one job, one reason to change.