Skip to content

Memento Design Pattern

Behavioral design pattern

Behavioral pattern

Memento design pattern lets you save and restore the previous state of an object without revealing the details of its implementation.

Let’s say you want to create a software with undo* behaviour (i.e. a notebook app or even a map planner).

Before performing any operation, the app records the state of all objects and saves it in some kind of storage.

Then, when a user decides to revert an action, the app fetches the latest snapshot of the app from the history and uses it to restore the state of all objects. The problem is