O'Reilly logo

Design Patterns in Modern C++: Reusable Approaches for Object-Oriented Software Design by Dmitri Nesteruk

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

© Dmitri Nesteruk 2018

Dmitri Nesteruk, Design Patterns in Modern C++, https://doi.org/10.1007/978-1-4842-3603-1_18

18. Memento

Dmitri Nesteruk

(1)St. Petersburg, Russia

When we looked at the Command design pattern, we noted that recording a list of every single change theoretically allows you to roll back the system to any point in time—after all, you’ve kept a record of all the modifications.

Sometimes, though, you don’t really care about playing back the state of the system, but you do care about being able to roll back the system to a particular state, if need be.

This is precisely what the Memento pattern does: it stores the state of the system and returns it as a dedicated, read-only object with no behavior of its own. This “token,” if you will, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required