Bird
0
0
LLDsystem_design~20 mins

When to use which behavioral pattern in LLD - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Behavioral Patterns Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Choosing the Right Behavioral Pattern for Communication

You have a system where multiple objects need to communicate without tight coupling. Which behavioral pattern is best suited to facilitate this communication?

AObserver pattern to notify objects about state changes.
BStrategy pattern to select algorithms at runtime.
CCommand pattern to encapsulate requests as objects.
DIterator pattern to traverse elements sequentially.
Attempts:
2 left
💡 Hint

Think about a pattern that helps objects stay updated about changes in others without direct dependencies.

Architecture
intermediate
2:00remaining
Selecting a Behavioral Pattern for Undo Functionality

You are designing a text editor that supports undo and redo operations. Which behavioral pattern should you use to encapsulate user actions?

AState pattern to manage object states.
BMediator pattern to coordinate actions between components.
CCommand pattern to encapsulate requests as objects.
DVisitor pattern to separate algorithms from objects.
Attempts:
2 left
💡 Hint

Consider a pattern that allows storing and executing actions as objects, enabling undo and redo.

scaling
advanced
2:30remaining
Scaling Event Handling in a Large System

In a large distributed system, you want to handle events efficiently without tight coupling between event producers and consumers. Which behavioral pattern helps scale event handling?

AObserver pattern to notify subscribers of events.
BChain of Responsibility pattern to pass requests along a chain.
CTemplate Method pattern to define skeleton of an algorithm.
DMemento pattern to capture and restore object state.
Attempts:
2 left
💡 Hint

Focus on a pattern that supports multiple subscribers reacting to events independently.

tradeoff
advanced
2:30remaining
Tradeoffs Between State and Strategy Patterns

You need to design a system where an object changes its behavior based on its internal state. You consider using either the State or Strategy pattern. What is a key tradeoff between these two patterns?

AStrategy pattern tightly couples states; State pattern decouples them.
BStrategy pattern changes object state automatically; State pattern does not.
CState pattern is used only for UI components; Strategy is for algorithms.
DState pattern manages state transitions internally; Strategy requires external management.
Attempts:
2 left
💡 Hint

Think about who controls the switching of behaviors in each pattern.

estimation
expert
3:00remaining
Estimating Capacity for Command Pattern in High-Load System

You implement the Command pattern to queue user requests in a high-load system. If each command object averages 1KB and you expect 10,000 commands per second with a retention time of 5 minutes, estimate the memory needed to store commands in the queue.

AApproximately 600 MB of memory.
BApproximately 3 GB of memory.
CApproximately 1 GB of memory.
DApproximately 500 MB of memory.
Attempts:
2 left
💡 Hint

Calculate total commands stored = commands per second * retention time in seconds, then multiply by size per command.