Skip to Main Content
Java Design Patterns: A Hands-On Experience with Real-World Examples
book

Java Design Patterns: A Hands-On Experience with Real-World Examples

by Vaskaran Sarcar
December 2018
Intermediate to advanced content levelIntermediate to advanced
512 pages
8h 51m
English
Apress
Content preview from Java Design Patterns: A Hands-On Experience with Real-World Examples
© Vaskaran Sarcar 2019
Vaskaran SarcarJava Design Patternshttps://doi.org/10.1007/978-1-4842-4078-6_19

19. Memento Pattern

Vaskaran Sarcar1 
(1)
Bangalore, Karnataka, India
 

This chapter covers the memento pattern.

GoF Definition

Without violating encapsulation, capture and externalize an object’s internal state so that the object can be restored to this state later.

Concept

In your application, you may need to support “undo” operations. To achieve this, you need to record the internal state of an object. So, you must save this state information in a place that can be referred again to revert back the old state of the object. But in general, objects encapsulate their states, and those states are inaccessible to the outer world. So, if you expose the state ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Design Patterns: A Hands-On Experience with Real-World Examples

Java Design Patterns: A Hands-On Experience with Real-World Examples

Vaskaran Sarcar
Spring Microservices in Action, Second Edition

Spring Microservices in Action, Second Edition

John Carnell, Illary Huaylupo Sanchez
Java Concurrency in Practice

Java Concurrency in Practice

Brian Goetz, Tim Peierls, Joshua Bloch, Joseph Bowbeer, David Holmes, Doug Lea

Publisher Resources

ISBN: 9781484240786Purchase LinkPublisher Website