Category Archives: Tutorial

Tutorial for learning programming or whatever.

Applying Command pattern in a demo of undoable actions.

In programming, we are usually need to queue requests, or decouple implementation of requests from its caller. And this is reason Command pattern was given birth. The Command pattern, basically, allows us encapsulate commands into objects. Thereby, it provides some useful options, such as:

  • Queue or dequeue requests
  • Parameterize client with different requests
  • Support redo/undo functionality

The implementation of Command pattern is quite simple with four major terms: Receiver, Invoker, Command, ConcreteCommand and Client. Let take a look at bellow diagram: Continue reading