2015-08-13 23:54:40 +02:00
|
|
|
---
|
|
|
|
layout: pattern
|
|
|
|
title: Memento
|
|
|
|
folder: memento
|
2015-08-15 18:03:05 +02:00
|
|
|
permalink: /patterns/memento/
|
2015-08-16 17:07:36 +05:30
|
|
|
categories: behavioral
|
2015-08-13 23:54:40 +02:00
|
|
|
tags: pattern_tag
|
|
|
|
---
|
|
|
|
|
|
|
|
**Intent:** Without violating encapsulation, capture and externalize an
|
|
|
|
object's internal state so that the object can be restored to this state later.
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
**Applicability:** Use the Memento pattern when
|
|
|
|
|
|
|
|
* a snapshot of an object's state must be saved so that it can be restored to that state later, and
|
|
|
|
* a direct interface to obtaining the state would expose implementation details and break the object's encapsulation
|
|
|
|
|
|
|
|
**Real world examples:**
|
|
|
|
|
2015-08-15 18:03:05 +02:00
|
|
|
* [java.util.Date](http://docs.oracle.com/javase/8/docs/api/java/util/Date.html)
|