0
0
LLDsystem_design~20 mins

Single Responsibility Principle in LLD - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
SRP Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Identify the Single Responsibility Principle Violation

Which of the following class designs violates the Single Responsibility Principle (SRP)?

AA class dedicated solely to formatting reports.
BA class responsible only for logging system events.
CA class that only manages database connections.
DA class that handles user authentication and also sends email notifications.
Attempts:
2 left
💡 Hint

SRP means a class should have only one reason to change.

Architecture
intermediate
2:00remaining
Refactoring for Single Responsibility Principle

You have a class that manages both user data validation and user data storage. How should you refactor it to follow SRP?

ASplit the class into two: one for validation and one for storage.
BKeep the class as is but add more methods for other user operations.
CRemove validation and only keep storage in the class.
DMerge the class with another class that handles user interface.
Attempts:
2 left
💡 Hint

Think about separating concerns into distinct classes.

scaling
advanced
2:00remaining
Scaling Impact of Violating Single Responsibility Principle

What is a likely consequence of violating SRP in a large-scale system?

AFaster deployment due to fewer classes.
BImproved modularity and easier testing.
CChanges in one feature cause unexpected bugs in unrelated features.
DReduced code duplication across modules.
Attempts:
2 left
💡 Hint

Consider how tightly coupled responsibilities affect maintenance.

tradeoff
advanced
2:00remaining
Tradeoff of Strict Single Responsibility Principle Adherence

What is a potential downside of strictly applying SRP by creating many small classes?

AIncreased complexity in managing many small classes.
BReduced code readability due to fewer classes.
CHigher risk of duplicated code within classes.
DLess flexibility in changing individual components.
Attempts:
2 left
💡 Hint

Think about the overhead of many small parts in a system.

component
expert
3:00remaining
Determining Single Responsibility in a Microservice

A microservice handles user profile updates, notification sending, and analytics tracking. Which change best aligns it with SRP?

AAdd caching to the existing microservice to improve performance.
BSplit the microservice into three: one for profile updates, one for notifications, and one for analytics.
CCombine this microservice with the authentication microservice for better integration.
DKeep all features but separate them into different methods within the same microservice.
Attempts:
2 left
💡 Hint

SRP applies to services as well as classes.