Memento (design pattern)
E679877
Memento (design pattern) is a behavioral software design pattern that captures and externalizes an object's internal state so it can be restored later without violating encapsulation.
Observed surface forms (3)
| Surface form | Occurrences |
|---|---|
| Caretaker (Memento pattern) | 0 |
| Memento object | 0 |
| Originator (Memento pattern) | 0 |
Statements (47)
| Predicate | Object |
|---|---|
| instanceOf |
behavioral design pattern
ⓘ
software design pattern ⓘ |
| alsoKnownAs | Token ⓘ |
| appliesTo |
objects with complex internal state
ⓘ
systems requiring reversible operations ⓘ |
| benefit |
decouples state storage from state management logic
ⓘ
simplifies Originator’s interface for saving and restoring state ⓘ |
| category | Gang of Four behavioral pattern NERFINISHED ⓘ |
| consequence |
can increase memory usage due to stored states
ⓘ
can increase number of objects created ⓘ |
| definedIn | Design Patterns: Elements of Reusable Object-Oriented Software NERFINISHED ⓘ |
| describedBy | Gang of Four NERFINISHED ⓘ |
| encapsulationLevel |
black-box memento
ⓘ
wide-interface memento ⓘ |
| ensures | Originator’s internal state is not exposed to other objects ⓘ |
| field |
object-oriented programming
ⓘ
software engineering ⓘ |
| hasIntent |
capture and externalize an object’s internal state so it can be restored later
ⓘ
preserve encapsulation while saving and restoring state ⓘ |
| hasParticipant |
Caretaker
NERFINISHED
ⓘ
Memento object ⓘ Originator NERFINISHED ⓘ |
| introducedIn | 1994 ⓘ |
| involvesRole |
Caretaker
NERFINISHED
ⓘ
Memento NERFINISHED ⓘ Originator ⓘ |
| languageAgnostic | true ⓘ |
| preserves | encapsulation ⓘ |
| relatedTo |
Command (design pattern)
NERFINISHED
ⓘ
Prototype (design pattern) NERFINISHED ⓘ State (design pattern) NERFINISHED ⓘ |
| responsibility |
create a memento containing a snapshot of its current internal state
ⓘ
keep track of mementos ⓘ pass mementos back to the Originator for state restoration ⓘ provide state back to the Originator when requested ⓘ request mementos from the Originator ⓘ restore its internal state from a memento ⓘ store the internal state of the Originator ⓘ |
| roleIn |
Memento (design pattern)
NERFINISHED
ⓘ
Memento (design pattern) NERFINISHED ⓘ Memento (design pattern) NERFINISHED ⓘ |
| supports |
rollback of state
ⓘ
state history management ⓘ undo operations ⓘ |
| useCase |
implement checkpoints in games
ⓘ
implement multi-level undo in text editors ⓘ implement transactional rollback in applications ⓘ |
Referenced by (3)
Full triples — surface form annotated when it differs from this entity's canonical label.
subject surface form:
Originator
subject surface form:
Caretaker