Over a million developers have joined DZone.

The Memento Pattern

Learn how API management supports better integration in Achieving Enterprise Agility with Microservices and API Management, brought to you in partnership with 3scale


The Memento captures and externalizes an object’s internal state so that the object can later be restored to that state. Command can use Memento to maintain the state required for an undo operation. It lets you capture an object’s state so you can restore the object later, so it's very useful for an undo operation.

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


Provides easy to implement recovery capability.

When to use:

  •  A snapshot of an object’s state must be saved so that it can be restored to that state later
  • Using a direct interface to obtain the state would expose implementation details and break the object’s encapsulation


Unleash the power of your APIs with future-proof API management - Create your account and start your free trial today, brought to you in partnership with 3scale.


Published at DZone with permission of Cristian Chiovari, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}