Command Pattern


  • The Command pattern creates distance between the client that requests an operation and the object that can perform it.

Class diagram: (see Command Pattern code review)

Command Pattern class diagram of sample code download


Use the Command Pattern when you want to:

  • Specify, queue, and execute commands at different times.
  • Support an Undo function for commands.
  • Support auditing and logging of all changes via commands.