Skip to content

Commit b75d1e6

Browse files
committed
start studying memento pattern
1 parent df97dca commit b75d1e6

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* [Strategy](behavioral/strategy) [:notebook:](https://en.wikipedia.org/wiki/Strategy_pattern)
1111
* [Command](behavioral/command) [:notebook:](https://en.wikipedia.org/wiki/Command_pattern)
1212
* [Template](behavioral/template) [:notebook:](https://en.wikipedia.org/wiki/Template_pattern)
13+
* [Memento](behavioral/memento) [:notebook:](https://en.wikipedia.org/wiki/Memento_pattern)
1314

1415
## [Creational](creational)
1516

behavioral/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ We are going to deal with behaviors instead of define structures or encapsulate
88
* [Chain of Responsibility](chain) [:notebook:](https://en.wikipedia.org/wiki/Chain-of-responsibility_pattern)
99
* [Command](command) [:notebook:](https://en.wikipedia.org/wiki/Command_pattern)
1010
* [Template](template) [:notebook:](https://en.wikipedia.org/wiki/Template_pattern)
11+
* [Memento](memento) [:notebook:](https://en.wikipedia.org/wiki/Memento_pattern)

behavioral/memento/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Behavioral » Memento
2+
3+
## Description
4+
5+
The memento pattern provides the ability to restore an object to its previous
6+
state (undo via rollback). It is implemented with three elements:
7+
8+
- originator
9+
- caretaker
10+
- memento
11+
12+
The originator is an object that has an internal state. The caretaker change
13+
the originator's state, but wants to be able to undo the change. The caretaker
14+
first asks the originator for a memento object. Then it does whatever operation
15+
it was going to do. To roll back it returns the memento object to the
16+
originator.
17+
18+
19+
## Implementation
20+

0 commit comments

Comments
 (0)