Introduction to Command mode (Brief Introduction)
Command pattern encapsulates the request as an object, allowing you to parameterize clients with different requests, queue or record request logs, and support revocable operations.
Encapsulate a request as an object, thereby letting your parameterize clients with different requests, queue or log request s, and support undoable operations
Ii. issues addressed (What to Solve)
Consider using command mode when you need to have a undo or redo operation.
Command mode Analysis 1, Command mode structure
Command abstract class: declares an interface for performing operations, declares an interface for executing a operation.
Concretecommand implementation class: Binds a Recipient object to an action. Invokes the corresponding action of the receiver to implement execute.
Defines a binding between a Receiver object and an action
Implements Execute by invoking the corresponding operation (s) on Receiver.
Receiver class: Know how to perform a request-related operation. Knows the perform the operations associated with carrying out the request.
Invoker class: Requires the command to execute a request. asks the command to carry out the request.