Please enable JavaScript.
Coggle requires JavaScript to display documents.
Command (aka Action, Transaction) (Key Objects (Client - Creates a…
Command (aka Action, Transaction)
Intent
Encapsulate a request as an object so other objects can be parameterized with different requests. Can also queue or log requests or support undoable actions.
Implementation
How intelligent should a command be? Can be a simple binding or replace the function of the receiver
-
Error accumulation needs to be avoided in the undo process. As undo and redo are performed, errors can accumulate. Memento pattern can be used to store more information about original state
Motivation
Sometimes need to issue requests to objects without knowing anything about the operation or the receiver. Command Pattern helps in this case
Helps decouple the client and the receiver, i.e the object that invokes an operation from the one who knows how to perform it.
-
Key Objects
-
-
Concrete Command - Implements interface, executes operation on receiver
-
-
-
Consequences
-
-
-
Easy to add new commands, existing classes need not be changed
-