© Vaskaran Sarcar 2018
V. SarcarDesign Patterns in C#https://doi.org/10.1007/978-1-4842-3640-6_19

19. Memento Pattern

Vaskaran Sarcar1  
(1)
Whitefield, Bangalore, Karnataka, India
 

This chapter covers the Memento pattern.

GoF Definition

Without violating encapsulation, capture and externalize an object’s internal state so that the object can be restored to this state later.

Concept

The dictionary definition of the word memento is that it’s a reminder of past events. When using this pattern, you can restore an object to its previous state. This pattern provides an object-oriented way to save the state of an object.

Real-Life Example

You can see a classic example of the Memento pattern in the states of a finite state machine. This pattern is a mathematical ...

Get Design Patterns in C#: A Hands-on Guide with Real-World Examples now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.