Chapter 19. Memento

Sometimes the object you want to create is one that existed previously. This occurs when you want to let a user undo operations, revert to an earlier version of work, or resume work that he or she previously suspended. The intent of the MEMENTO pattern is to provide storage and restoration of an object's state.

A Classic Example—Using Memento for Undo

Chapter 17, “Abstract Factory,” introduced a visualization application that let users perform operational modeling experiments with material flow through a factory. Suppose that the functionality for the Undo button has not yet implemented. We can apply the MEMENTO pattern to make the Undo button work.

A memento is an object that holds state information. In the visualization application, ...

Get Design Patterns in C# now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.