jargon

Design patterns·Who calls whom, and when

the object handed out an opaque snapshot of itself that only it can read, and later took it back to undo.

Memento pattern

Also calledmemento, snapshot object, undo token

Capturing an object's internal state in a form something else can hold but not inspect, so it can be restored later. The encapsulation constraint is what distinguishes it from just copying the fields — the caretaker gets a token, not the data. Almost nobody names it in production code, but it is the honest description of every undo stack and editor snapshot, and it is asked about.

Commonly confused with