CSE Roadmap

Core tier · about 3 hours · 6 parts

Part 1 of 6 · 1 min read

Why this page comes fourth

In this module you will

  • State the Command pattern and name its parts: command, receiver, invoker and client.
  • Write commands with execute and undo for a small schedule.
  • Build undo and redo with two stacks.
  • Group commands into a macro and run them from a queue.
  • Say when a plain method call or a lambda is enough.

Strategy, observer and state each decide how objects react. Command is about requests themselves: it makes a request into a thing that can be stored, passed around, delayed, repeated and reversed. Editors, task queues and job systems all rely on it. The source is "Design Patterns" (GoF) chapter 5, with the same idea in "Head First Design Patterns" (HF) chapter 6. Code was compiled and run before it was written here. Numbers marked "made up" only show the idea.