Undo

4 important aspects that are discussed:

  1. Undoable Actions: what actions should (or can) be undone?
  2. State restoration: what part of UI is restored after undo?
  3. Granularity: how much should be undone at a time?
  4. Scope: is undo global, local, or someplace in between?

Recommendations for Undo Granularity

  • Ignore direct manipulation intermediate states
    • e.g. ignore mousemove during object resize or move states
  • Delimit chunks on discrete “input breaks“
    • e.g. words in text
  • Chunk all changes resulting from a single interface event
    • e.g. find and replace multiple words

Forward Undo

Forward Undo

  • Start from base document, then maintain of list of changes to compute current document
  • Undo by removing last change from list when computing current document

Reverse Undo

  • Apply change to update document, but also save “reverse” change
  • Undo by applying reverse change to document

How to implement reverse change? 2 options:

Option 1: Command pattern

  • save command and “reverse command” to change state

Option 2: Memento pattern

  • save snapshots of each document state
  • could be complete state or difference from “last” state

The stacks of Forward and Reverse Undo