Command Pattern
Command Pattern Intent Also known as “Action” or “Transaction” Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests,and support undoable operations. Also known as “Action” or “Transaction” Motivating example GUI button or menuitem, when clicked, do some action. The button or menuitem (the invoker) do not have to know what actions are being carried out and by whom (the receiver)
(Imperfect) Diner Analogy Customer (client); Order (command); Waitress (invoker); Cook (receiver);
Home Automation Remote Example
Ventor Supplied Classes
Command Object
Command Pattern Defined
Command Pattern Class Diagram
Implement Remote Control
Support Undo
Undo with State
MacroCommand
Use Case: Queuing Requests
Use Case: Logging Requests