What does the Single Responsibility Principle (SRP) mean?

Answer

The Single Responsibility Principle states that a class should have only one reason to change, meaning it should have only one job or responsibility. A class that handles user authentication, sends emails, and writes audit logs has three reasons to change — violating SRP. Splitting it into AuthService, EmailService, and AuditLogger gives each class a single, well-defined purpose. SRP makes code easier to understand, test, and maintain. When requirements change for one concern (e.g., switching from SMTP to SendGrid), only the relevant class needs modification, reducing the risk of breaking unrelated functionality.