Command Design Pattern in Java

The command pattern comes under behavioral design pattern. The Command pattern is used to create objects that represent actions and events in an application. In the command pattern, a command interface declares a method for executing a particular action. A command object encapsulates an action or event and contains all information required to understand the action or event. This command object can be used as a parameter to extract information about occurred actions and events.

In the command pattern, the invoker is decoupled from the action performed by the receiver. The invoker invokes a command that executes the appropriate action of the receiver. Hence invoker is unaware of details of the action to be performed.

The command pattern can be used to perform redo/undo functionality. Continue reading “Command Design Pattern in Java”