The memento pattern relies on three classes: Originator, Memento, and Caretaker, as shown in the following class diagram:
The memento pattern relies on the following classes:
- Originator: The originator is the object for which we need to memorize the state in case we need to restore it at some point.
- Caretaker: This is the class responsible for triggering the changes in the originator or for triggering an action through which the originator returns to a previous state.
- Memento: This is the class responsible for storing the internal state of the originator. Memento provides two methods by which to set and get a state, but those ...