Design pattern for undo operation with Makie

We have GUI program where it would be useful to have an UNDO button: Add undo button · Issue #7 · bradcarman/ModelingToolkitDesigner.jl · GitHub

Is there any suggestion how to implement this?

EDIT: Article related to C#: Multilevel Undo and Redo Implementation in C# - Part I (Using Single Object Representing Change Approach) - CodeProject

These C++ talks by Sean Parent might also be useful for inspiration for undo/redo implementations:

Guess the classic OOP solution would be the memento pattern. A particularly easy approach to achieve that, would be by using immutable data structures which can basically act as there own snapshot at any time.
Another approach would be to reify actions into a data type and store the sequence of all applied actions, which can then be (partially) replayed at will later on, i.e., as in the command pattern which is also common to support undo/redo operations.
Finally, here is a nice wrap-up showing how these (as well as most other OOP patterns) become easier in a language (Clojure) with first class functions and immutable data structures.

1 Like