Memento Flashcards

1
Q

Intent

A

Without breaking encapsulation, capture and externalize an object’s internal state.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Motivation

A

Store a snapshot of the internal state of another object, originator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Structure

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Participants

A
  • Memento
    • stores the internal state of the Originator
    • Mementos have two interfaces: narrow interface (Caretaker) and wide interface (Originator)
  • Originator
    • creates a memento containing a snapshot of its current internal state
    • uses the memento to restore its internal state
  • Caretaker
    • responsible for the memento’s safekeeping
    • never examines or operates on the contents of memento
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Related Patterns

A
  • Command
  • Iterator
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Collaborations

A

Caretaker (client) can request a memento from the originator (to save a snapshot) and pass a memento back to the originator (to restore previous state)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

AKA

A

Token

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the role of a Caretaker

A

Setting and getting the memento.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Does the Caretaker have access to the contents of a memento?

A

No

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which participant stores the internal state of which object?

A

Memento stores the internal state of Originator.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Mementos have two interfaces, narrow and wide. Which participants are what?

A
  • Originator* is wide interface.
  • Caretaker* is narrow interface.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly