A classic example of the memento design pattern that comes to mind is text editors. We can always undo whatever we have changed. We will present something similar in our class diagram and example.
The following is the class diagram:
As you can see in the preceding diagram, our caretaker is the TextEditorManipulator. It automatically saves the state in the states stack on every manipulation. The TextEditor implements the Originator and creates a memento object and restores from one. Finally, the TextEditorMemento is the concrete memento object that our text editor will be using to save the state. Our state is just the ...