Please enable JavaScript.
Coggle requires JavaScript to display documents.
Memento aka Token (Consequences (Mementos may be Expensive If Originators…
Memento aka Token
Consequences
Mementos may be Expensive If Originators are large or complex, the Memento objects may be large and expensive to store
Defining narrow and wide interfaces It may be difficult in some languages to ensure that only the Originator can access the state
It Simplifies Originator - In some models, the Originator is responsible for storing its own state, puts a heavy burden. In this case, the client is responsible for storing the state
Hidden costs in caring for MementosThe caretaker has no idea of the size of memento, a light-weight caretaker may to support heavy weight mementos
Preserving Encapsulation Boundaries Memento avoids exposing the Originators internal state to external objects when Originator has to be stored externally
Motivation
Objects encapsulate their internal state, external objects are not able to access it.
To support checkpoint and undo operations, the internal state of an object has to be stored externally
Memento object stores the externalized state of the Originator. Client that supports Undo operation requests the Memento, stores it and passes it back to Originator when the Undo is required
Key Objects
-
-
Memento
Stores internal state of Originator, stores as much
state as required
-
-
-
-
-