Persisting Mementos across Sessions

A session occurs when a user runs a program, conducts transactions in the program, and exits. Suppose that your users want to be able to save a simulation in one session and restore it in another session. This ability is a matter normally referred to as persistent storage. Persistent storage fulfills the intent of the MEMENTO pattern and is a natural extension to the undo functionality you have already implemented.

Suppose that you subclass the Visualization class with a Visual-ization2 class[1] that has a menu bar with a File menu. This menu offers Save and Load commands that you link to action methods:

[1] The Visualization2 class's name ends with a number but no underscore, to indicate that it is a revision ...

Get Design Patterns Java™ Workbook 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.