The Memento Pattern

archetype Social RolesObject-Oriented Design

Categories: software-engineering

What It Brings

A memento is a keepsake — a pressed flower, a ticket stub, a photograph — an object kept specifically because it preserves a moment that would otherwise be lost. The GoF Memento pattern maps this sentimental practice onto software: an object’s internal state is captured in a token that can be stored and used later to restore the object to its former condition. The metaphor makes snapshot-and-restore feel intimate and purposeful rather than merely technical.

Key structural parallels:

Where It Breaks

Expressions

Origin Story

The Memento pattern was codified by the Gang of Four in Design Patterns (1994). The name is notably more evocative than most GoF pattern names — where “Factory” and “Observer” are functional descriptions, “Memento” is poetic. The Latin root memento means “remember” (as in memento mori, “remember that you will die”). The choice to name a state-capture mechanism after keepsakes rather than calling it “Snapshot” or “Checkpoint” was a deliberate framing decision. It emphasizes the purpose (preserving something meaningful) over the mechanism (serializing state), and it lends emotional resonance to what is fundamentally a serialization pattern.

References

Related Mappings