← All Quizzes
What is the Single Responsibility Principle (SRP)?
Explanation
The Single Responsibility Principle (SRP), the S in SOLID, states that a class or module should have only one reason to change, meaning it should have a single responsibility. This does not mean one method per class, but that all methods should serve the same purpose. SRP improves maintainability, testability, and reduces coupling. Violations occur when a class handles multiple concerns (e.g., business logic and data persistence). Separating concerns makes code easier to understand, modify, and test.