Java Reference
In-Depth Information
storage only: specifically, the storage of an object's data in another object. If you widen
the meaning of memento to include offline storage, arguably every database row and every
XML string that contains an object's state is a memento. Possibly for these reasons, Design
Patterns does not provide any offline storage examples of M EMENTO .
On the other hand, M EMENTO and persistent storage both capture and externalize an object's
internal state. An XML string may lie somewhere between an online memento and a database,
placing an object's state in a machine-readable and human-readable form. If you say you
create mementos by storing an object's data in an XML string, I will understand what you
mean. And that's the point of design patterns: By using a common vocabulary, we can readily
discuss design concepts and their application.
Summary
The M EMENTO pattern lets you capture an object's state so you can restore the object later.
The means of storage may depend on whether you need to be able to restore an object after a
few clicks and keystrokes or after days or years. The most common reason for saving and
restoring objects during an application session is the support of undo operations. In such a
case, you can store an object's state in another object, possibly a clone. To let an object persist
across sessions, you can save the memento either through object serialization or as text that
you will parse to restore the object.
Search WWH ::




Custom Search