Skip to content

Commit ca6bb7a

Browse files
committed
Improve Memento Javadoc
1 parent fc66ae8 commit ca6bb7a

File tree

1 file changed

+14
-1
lines changed
  • memento/src/main/java/com/iluwatar/memento

1 file changed

+14
-1
lines changed

memento/src/main/java/com/iluwatar/memento/App.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,20 @@
44

55
/**
66
*
7-
* Memento pattern is for storing and restoring object state. The object ({@link Star})
7+
* The Memento pattern is a software design pattern that provides the ability to restore
8+
* an object to its previous state (undo via rollback).
9+
* <p>
10+
* The Memento pattern is implemented with three objects: the originator, a caretaker and
11+
* a memento. The originator is some object that has an internal state. The caretaker is
12+
* going to do something to the originator, but wants to be able to undo the change. The
13+
* caretaker first asks the originator for a memento object. Then it does whatever operation
14+
* (or sequence of operations) it was going to do. To roll back to the state before the
15+
* operations, it returns the memento object to the originator. The memento object itself
16+
* is an opaque object (one which the caretaker cannot, or should not, change). When using
17+
* this pattern, care should be taken if the originator may change other objects or
18+
* resources - the memento pattern operates on a single object.
19+
* <p>
20+
* In this example the object ({@link Star})
821
* gives out a "memento" ({@link StarMemento}) that contains the state of the object.
922
* Later on the memento can be set back to the object restoring the state.
1023
*

0 commit comments

Comments
 (0)