What is the Command design pattern?

Answer

The Command pattern encapsulates a request as an object, allowing you to parameterize clients with different requests, queue them, log them, and support undoable operations. Each command object implements an execute() method. For example, a text editor's "Bold" action becomes a BoldCommand object. This enables: storing commands in a history stack for undo/redo, serializing commands to a queue for scheduled execution, and implementing macro recording by grouping multiple commands. GUI buttons that execute different actions depending on context are a textbook use case.