Mรณdulo 27 ยท Design Patterns (All 23 GoF) โ Lecciรณn 18 de 23 ยท ~6 min
Memento
Capture state now, restore it later
Memento snapshots an object's internal state into a separate token so you can restore it later โ without exposing how the object stores things. A booking draft can be saved before risky edits; if the user cancels, you put the saved state back.
The memento is just captured data (often a dict copy). save_state() produces it; restore(memento) writes it back.