Skip to content
StackDecode
System Design
15. Software Design PatternsAnimated walkthrough

Command Pattern

Turn a request into an object.

The idea

Commands can be queued, logged, undone and replayed.

Watch it work

The steps light up one at a time. Use the controls to pause or step through.

  1. 1Create a command object
  2. 2Store or queue it
  3. 3Execute it
  4. 4Undo if needed
1/4

Step by step

  1. 1Create a command object
  2. 2Store or queue it
  3. 3Execute it
  4. 4Undo if needed

Where it is used

Undo and job queues.

Watch out for

Many small classes.

Related