Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marlonmontenegro/mementopattern
The Memento Pattern is a behavioral design pattern that provides a way to capture and externalize the internal state of an object without exposing its internal structure. This allows you to save the object's state at a specific point in time and restore it later, effectively providing the ability to undo or roll back changes made to the object.
https://github.com/marlonmontenegro/mementopattern
Last synced: about 1 month ago
JSON representation
The Memento Pattern is a behavioral design pattern that provides a way to capture and externalize the internal state of an object without exposing its internal structure. This allows you to save the object's state at a specific point in time and restore it later, effectively providing the ability to undo or roll back changes made to the object.
- Host: GitHub
- URL: https://github.com/marlonmontenegro/mementopattern
- Owner: MarlonMontenegro
- Created: 2023-09-27T19:02:34.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-27T19:13:45.000Z (over 1 year ago)
- Last Synced: 2023-09-28T06:34:32.777Z (over 1 year ago)
- Language: Java
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MementoPattern
The Memento Pattern is a behavioral design pattern that provides a way to capture and externalize the internal state of an object without exposing its internal structure. This allows you to save the object's state at a specific point in time and restore it later, effectively providing the ability to undo or roll back changes made to the object.![image](https://github.com/MarlonMontenegro/MementoPattern/assets/103525183/3be4e3cc-7a0e-4197-91f5-844a7b826ec3)
Originator: This is the object whose state needs to be saved. It creates a Memento object to store its internal state and can also restore its state from a Memento.
Memento: The Memento is an object that stores the internal state of the Originator. It does so without exposing the details of that state. It typically provides methods to get and set the state.
Caretaker: The Caretaker is responsible for keeping track of Memento objects. It doesn't operate on or modify the Mementos; instead, it stores them and can later provide them back to the Originator to restore its state.
Here's a basic sequence of actions in the Memento Pattern:
The Originator creates a Memento object to store its current state.
The Originator sets its state (possibly making changes).
The Originator can save the Memento to a Caretaker.
Later, if needed, the Originator can request the state to be restored from a specific Memento stored by the Caretaker.