GoF Design Patterns – Memento Design Pattern


The Memento design pattern is a behavioral pattern that allows an object to capture and store its internal state so that it can be restored later if needed. It provides a way to undo or rollback an object’s state to a previous state without violating its encapsulation. The pattern is useful when implementing undo/redo functionality with history, as well as when the state of an object needs to be saved for later use. The main benefit of this pattern is the ability to implement capture and store state operations without exposing details of object implementation. This allows for the separation of concerns and allows to easily evolve objects whose state needs to be captured and restored without having to change the code that manages undo history.

More on this pattern…

To read more on this and the other patterns, get “GoF Design Patterns Distilled” book from Amazon or Leanpub: