System Design
15. Software Design PatternsAnimated walkthrough
Memento Pattern
Save and restore an object's state.
The idea
A snapshot object lets you undo without breaking encapsulation.
Watch it work
The steps light up one at a time. Use the controls to pause or step through.
- 1Originator creates a snapshot
- 2Caretaker stores it
- 3Later restore from it
- 4State returns
1/4
Step by step
- 1Originator creates a snapshot
- 2Caretaker stores it
- 3Later restore from it
- 4State returns
Where it is used
Undo features.
Watch out for
Snapshots can be memory-heavy.