Expand description

The Command design pattern example module

The Command pattern is used to encapsulate an operation or command associated with an object so that the command can be applied to the object at a later time.

In this exercise, an undo list is implemented using Commands that associate commands defined in this file with a text object. The commands are applied to the text object in succession then effectively undone.

Accessed through the command_exercise() function.

Modules

Structs

  • This struct creates a context around the undo list that the command_exercise() executes within. This gets around the problem of needing a static undo list (or passing the undo list to all functions) as all the methods on this context have ready access to the undo list in the context.

Functions