Skip to content
StackDecode
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.

  1. 1Originator creates a snapshot
  2. 2Caretaker stores it
  3. 3Later restore from it
  4. 4State returns
1/4

Step by step

  1. 1Originator creates a snapshot
  2. 2Caretaker stores it
  3. 3Later restore from it
  4. 4State returns

Where it is used

Undo features.

Watch out for

Snapshots can be memory-heavy.

Related