Memento Design Pattern - TechNet Articles - United States (English) - TechNet Wiki

This article describes the Memento design pattern. This is a behavioral design pattern, a category of design pattern used by software engineers, when writing computer programs.

Table of Contents

Memento Design Pattern

This article describes the Memento design pattern. This is a behavioral design pattern, a category of design pattern used by software engineers, when writingv>

Introduction

The Memento pattern is a design pattern, used in software engineering, to capture and externalize the internal state of an object, so that it can be saved, and restored to the same state at a later time. This pattern defines an "originator" (which needs to be saved and restored), a "caretaker" which controls when and why the originator save or loads itself, and the Memento itself, which saves information from the originator int the data storage object (file, database, cookie, etc)

It is defined as a behavioral design pattern, because the program executes the object based on the state information placed upon it from the stored values.

Benefits

Saving and restoring state is useful for returning to an operation or a view at a later stage, like undo and rollback functions.

Examples of the pattern

Undo, restore and rollback functions depend on a complete set of data relating to the previous state being stored and read back in.

Web page cookies are mementos, as they contain session information, used by the web page when you return.

Some word processing applications like Microsoft Word periodically save the document in temporary storage, in case of an unexpected exit from the application.

Microsoft Management Console uses a Memento to set the view to the specified memento's state.

 

Return to Top


See Also

Link to domain parent articles and related articles in TechNet Wiki.

 

 

Return to Top


Community Resources

These are the external links, including links to Microsoft and TechNet sites that are non-Wiki
  • [Please contribute]

 

 

Return to Top


References section

Use this section if you pulled source material and ideas from other sites, blogs, or forums. Make sure you have permission from authors to use their material.
  • [Please contribute]

 

 

Return to Top