Bird
0
0
LLDsystem_design~20 mins

Memento pattern in LLD - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Memento Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Purpose of the Memento Pattern
What is the primary purpose of the Memento pattern in software design?
ATo create a single instance of a class and provide a global point of access to it.
BTo capture and externalize an object's internal state so it can be restored later without violating encapsulation.
CTo define a family of algorithms, encapsulate each one, and make them interchangeable.
DTo separate the construction of a complex object from its representation so the same construction process can create different representations.
Attempts:
2 left
💡 Hint
Think about saving and restoring an object's state without exposing its details.
Architecture
intermediate
2:00remaining
Components of the Memento Pattern
Which of the following correctly identifies the three main components of the Memento pattern?
AOriginator, Memento, Caretaker
BSubject, Observer, ConcreteObserver
CBuilder, Director, Product
DComponent, Decorator, ConcreteDecorator
Attempts:
2 left
💡 Hint
Think about who creates the state, who stores it, and who manages it.
scaling
advanced
2:00remaining
Scaling Memento Pattern for Large State Objects
When using the Memento pattern for objects with large internal states, what is the best approach to optimize memory usage?
AUse incremental snapshots or delta changes to store only differences between states.
BAvoid using the Memento pattern and instead serialize the entire object to disk after each change.
CStore full copies of the state every time a change occurs to ensure complete rollback capability.
DKeep all mementos in memory indefinitely to allow unlimited undo operations.
Attempts:
2 left
💡 Hint
Think about storing only what changes instead of full copies.
tradeoff
advanced
2:00remaining
Trade-offs of Using the Memento Pattern
What is a common trade-off when implementing the Memento pattern in a system?
AIt increases coupling between objects, making the system harder to maintain.
BIt violates encapsulation by exposing internal state details to other objects.
CIt can lead to high memory consumption due to storing multiple object states.
DIt makes the system slower by requiring synchronous communication between components.
Attempts:
2 left
💡 Hint
Consider the cost of saving many states over time.
component
expert
3:00remaining
Request Flow in Memento Pattern
In a system using the Memento pattern, what is the correct sequence of interactions when saving and restoring an object's state?
A3,1,2,4
B2,1,3,4
C1,3,2,4
D1,2,3,4
Attempts:
2 left
💡 Hint
Think about who initiates the save and restore actions and the order of storing and restoring.