Command Pattern

Status: draft · Confidence: medium (0.635) · Basis: verified_sources

Quality notes: generic_source_homepage, no_verified_sources, partial_source_verification

## TL;DR

Encapsulates a request as an object, enabling parameterization, queuing, logging, and undo/redo. Commands are first-class objects with execute() and undo() methods.

## Core Explanation

Example: text editor with undo stack — each edit is a Command object pushed to history. Macro commands compose multiple commands. Used in: job queues, transactional systems, game input handling. CQRS (Command Query Responsibility Segregation) extends this to architecture level.

## Further Reading

- [Design Patterns (Gang of Four)](undefined)

## Related Articles

- [Adapter Pattern](../adapter-pattern.md)
- [Decorator Pattern](../decorator-pattern.md)
- [Factory Method Pattern](../factory-method-pattern.md)