Junior
From PDF
SOLID
Design Patterns & SOLID
What is the Single Responsibility Principle?
Short answer: The Single Responsibility Principle (SRP) states that a class should have only one reason to change. In other words, it should have only one responsibility or job. Each class should do one thing, and do it well. For example, a class that handles user authentication should not also be responsible for logging or sending emails.
Say this in the interview
- Define — one clear sentence (the short answer above).
- Example — relate it to a project like ShopNest or your real work.
- Trade-off — when you would not use it.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png