You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Provide the ability to restore an object to its previous state (undo via rollback).
6
+
7
+
The memento pattern is implemented with three objects: the originator, a caretaker and a memento.
8
+
The originator is some object that has an internal state.
9
+
The caretaker is going to do something to the originator, but wants to be able to undo the change.
10
+
The caretaker first asks the originator for a memento object. Then it does whatever operation (or sequence of operations) it was going to do.
11
+
To roll back to the state before the operations, it returns the memento object to the originator.
12
+
The memento object itself is an opaque object (one which the caretaker cannot, or should not, change).
13
+
When using this pattern, care should be taken if the originator may change other objects or resources - the memento pattern operates on a single object.
0 commit comments