AlgoViz

Command

medium 50 min

A command wraps a request in an object: what to do, with which receiver and parameters.

Chapter mnemonic

Four Command pattern roles

Diner writes the ticket. Waiter rings it in. Chef cooks.

The waiter rings in an order and the chef cooks it. Who invokes and who receives?

The waiter invokes the command. The chef is the receiver that performs the work.