O'Reilly logo

Design Patterns in C# by Steven John Metsker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required