Memento

Intent

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

††††† -Design Patterns, GoF

 

Structure

A class diagram from JavaWorld.com:

 

 

 

Questions

1) What is the purpose of the Memento?

2) Why do you need a special pattern to deal with this?Why canít any class have this responsibility?

3) What are the two interfaces that the Memento has?In Java, how can this be enforced?

4) Who can see the internals of the Memento?

5) What performance considerations should be taken into account before implementing this pattern?

6) How is it possible to reduce the storage of a Memento through incremental change?