Bird
0
0
LLDsystem_design~20 mins

Command pattern in LLD - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Command Pattern Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding the core purpose of the Command pattern

Which of the following best describes the main purpose of the Command pattern in software design?

ATo create a single instance of a class to control access to a resource.
BTo encapsulate a request as an object, allowing parameterization and queuing of requests.
CTo define a family of algorithms and make them interchangeable at runtime.
DTo separate the construction of a complex object from its representation.
Attempts:
2 left
💡 Hint

Think about how commands can be stored and executed later.

Architecture
intermediate
1:30remaining
Identifying components in a Command pattern architecture

In a typical Command pattern architecture, which component is responsible for executing the actual operation?

AReceiver
BClient
CInvoker
DCommand
Attempts:
2 left
💡 Hint

Consider which part knows how to perform the work.

scaling
advanced
2:00remaining
Scaling command execution in distributed systems

You want to design a system using the Command pattern that supports executing commands asynchronously across multiple servers. Which approach best supports scalability and fault tolerance?

ADistribute commands to multiple worker nodes via a message queue, allowing parallel processing and retries on failure.
BExecute commands synchronously on the client side to avoid network overhead.
CStore commands in a local file and process them in batches once a day.
DUse a centralized command queue with a single worker processing commands sequentially.
Attempts:
2 left
💡 Hint

Think about how to handle many commands efficiently and recover from failures.

tradeoff
advanced
2:00remaining
Tradeoffs of using the Command pattern for undo functionality

When implementing undo functionality using the Command pattern, what is a key tradeoff to consider?

AThe Command pattern cannot support undo operations effectively.
BUndo functionality requires commands to be stateless, simplifying design but limiting features.
CCommands must store state to reverse actions, increasing memory usage and complexity.
DUndo operations are automatically handled by the Invoker without extra code.
Attempts:
2 left
💡 Hint

Think about what is needed to reverse an action.

estimation
expert
2:30remaining
Estimating command queue capacity for a high-traffic system

A system uses the Command pattern with a command queue to handle user requests. The system expects 10,000 commands per second, each command averaging 5 KB in size. The queue should hold commands for up to 10 seconds to handle spikes. What is the minimum queue storage capacity required?

A50 MB
B500 KB
C5 GB
D500 MB
Attempts:
2 left
💡 Hint

Calculate total commands in 10 seconds and multiply by command size.