Build Undo/Redo

Command pattern

Challenge 1 of Actions as ObjectsIntermediate~55 minFree

See how design patterns and data structures build a real feature: undo/redo. You will implement the Command pattern over a document, drive it with two stacks, extend it with a new command type, and batch actions with the Composite pattern, the exact machinery behind every editor.

5 steps

  1. 1The Command Interface
  2. 2The Undo Stack
  3. 3The Redo Stack
  4. 4A New Command, For Free
  5. 5Batching with a Macro
Start step 1