MΓ³dulo 23 Β· Design Patterns (All 23 GoF) β LecciΓ³n 18 de 23 Β· ~6 min
Memento
Memento: capture state to restore later
Problem: you want undo β snapshot an object's state now, and put it back later β without exposing the object's internals to whoever holds the snapshot.
PawWalk scenario: a booking draft. Snapshot it before risky edits; on cancel, restore the snapshot.
The memento is just a copy of the fields. save_state returns it; restore copies it back.