"Design Mode Design Pattern" Reading Notes
Command mode
structure
purpose
The Command object establishes the connection between the command issuer (Invoker) and Receiver. Thus, INVOKER does not need to know who is Receiver, which only issues an Execute () request to Command, and Command automatically tells Receiver for the corresponding processing.
discuss
1. If Command needs undo / redo operation, you need to save various states, you can use the MEMENTO mode; if it is a string undo / redo command, then you need to connect these Command into a history list, if these Command is in the execution Will change, then you need Copy to History List, instead of using REFERENCE, you can use the prototype mode for COPY operations at this time.
2, if Command is simple, just establish the connection between Invoker and Receiver, you can use the template to make a universal Command template.
3, Composite mode can be used to implement Macrocommands (Collection of Command).
Reference
"Design Pattern" Gang-Of-4 1997