Skip to main content
InterviewHubPRO
Section Overview
Q39

Question 39 of 50

Part 3: Architectural Patterns & Enterprise Systems (25 - 35)

78%
Design Patterns (GoF) (50 Qs)•Part 3: Architectural Patterns & Enterprise Systems (25 - 35)

Memento Pattern: Snapshotting internal state for undo/redo workflows.

senior Leveldesign-patternsArchitectural Patterns

In Simple Words: Captures and externalizes an object's internal state so the object can be restored to this state later, without violating encapsulation:

  • Originator: The business object (e.g. Text Editor canvas). Creates a Memento containing its private state snapshot and can restore itself from a Memento.
  • Memento: Immutable state snapshot container.
  • Caretaker: Manages the undo/redo stack (holds array of Mementos), but never reads or modifies the state inside the Memento.