Memento Design Pattern

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 writing computer programs.

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


Leave a Comment
  • Please add 8 and 2 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
Comments
  • XAML guy edited Revision 2. Comment: tweak

  • XAML guy edited Revision 1. Comment: tidied sections

  • XAML guy edited Original. Comment: spell, tweak

Page 1 of 1 (3 items)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
  • XAML guy edited Original. Comment: spell, tweak

  • XAML guy edited Revision 1. Comment: tidied sections

  • XAML guy edited Revision 2. Comment: tweak

Page 1 of 1 (3 items)