# Command Pattern

Record: `arch:command-pattern`
Kind: pattern
Layer: [Design Patterns Core](https://banes-lab.com/records/layer/design-patterns-core.md)
Severity: recommended
Scope: behavior, invocation, workflow
Canonical: https://banes-lab.com/ontology#arch-command-pattern

## Repair

- Refactored by: Encapsulate Invocation as a Command object
- Detected by: switch/if chains selecting an operation to run
- Violated by: inline conditional dispatch on an action name
- Measured by: dispatch-branch count per action site
- Enforced by: [design review](https://banes-lab.com/records/arch/design-review.md)

## requires

- [Encapsulation](https://banes-lab.com/records/arch/encapsulation.md)

## reinforces

- [Open/Closed Principle (OCP)](https://banes-lab.com/records/arch/open-closed.md)
- [Single Responsibility Principle (SRP)](https://banes-lab.com/records/arch/single-responsibility.md)

## enables

- [Undo/Redo](https://banes-lab.com/records/lex/undo-redo.md)
- [Deferred Execution](https://banes-lab.com/records/lex/deferred-execution.md)
- [Request Queuing](https://banes-lab.com/records/lex/request-queuing.md)

## conflicts-with

- [Direct Method Invocation](https://banes-lab.com/records/lex/direct-method-invocation.md)

## tensions-with

- [Simplicity](https://banes-lab.com/records/lex/simplicity.md)

## tensions

- [Command Pattern Simplicity](https://banes-lab.com/records/tension/command-pattern-simplicity.md)
