Memento
Memento is a behavioral design pattern that lets you save and restore the previous state of an object without revealing the details of its implementation. Imagine that you’re creating a text editor app. In addition to simple text editing, your editor can format text, insert inline images, etc. At some point, you decided to let users undo any operations carried out on the text. This feature has become so common over the years that nowadays people expect every app to have it. For the implementation, you chose to take the direct approach. Before performing any operation, the app records the state of all objects and saves it in some storage. Later, when a user decides to revert an action, the app fetches the latest snapshot from the history and uses it to restore the state of all objects. Before executing an operation, the app saves a snapshot of the objects’ state, which can later be used to restore objects to their previous state. Let’s think about those state snapshots. How exactly woul
/ Design Patterns / Behavioral Patterns Memento Also known as: Snapshot Intent Memento is a behavioral design pattern that lets you save and restore the previous state of an object without revealing the details of its implementation. Problem Imagine that you’re creating a text editor app. In addition to simple text editing, your editor can format text, insert inline images, etc. At some point, you decided to let users undo any operations carried out on the text. This feature has become so common over the years that nowadays people expect every app to have it. For the implementation, you chose
Explore this link on the map →related reading
- Staterefactoring.guru
- How can we develop transformative tools for thought?numinous.productions
- mymind is the extension for your mind.mymind.com
- Design Patternsgrantslatton.com
- Design with materials, not features | thesephist.comthesephist.com
- artima - Josh Bloch on Designartima.com
- how I think when I think about programming - alice mazalicemaz.com
- Malleable software: Restoring user agency in a world of locked-down appsinkandswitch.com
- Design Patternsrefactoring.guru
- Memoization - Wikipediaen.wikipedia.org
- Immutable object - Wikipediaen.wikipedia.org
- Understanding useMemo and useCallback • Josh W. Comeaujoshwcomeau.com