Design Patterns Memento Pattern - Design Patterns

What is Design Pattern Memento Pattern?

Memento pattern is used to restore state of an object to a before state. Memento pattern falls in behavioural pattern group.


Memento pattern uses three performer classes. Reminder contains condition of an object to be restored. Originator creates and stores states in reminder objects and Caretaker object is responsible to restore object state from Memento. We have created course Memento, Originator and Caretaker.

MementoPatternDemo, our demo class, will use Caretaker and designer objects to illustrate return of object states.


Step 1

Create Memento class.

Step 2

Create Originator class

Step 3

Create Caretaker class

Step 4

Use Caretaker and Originator objects.

Step 5

Verify the output.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

Design Patterns Topics