The Command Pattern

archetype Military CommandObject-Oriented Design

Categories: software-engineering

What It Brings

A command in military parlance is an order from a superior to a subordinate: explicit, recorded, and executable. The GoF Command pattern reifies this: an operation becomes a first-class object that can be stored, transmitted, queued, and undone. The military metaphor makes this transformation feel natural — of course orders should be written down, filed, and potentially countermanded.

Key structural parallels:

Where It Breaks

Expressions

Origin Story

The Command pattern formalized a technique that predates the GoF book. Early menu systems and GUI frameworks needed to decouple button clicks from the operations they triggered — separating “the user clicked Undo” from “restore the previous document state.” The military naming likely entered through the influence of Smalltalk and early OOP practitioners who favored active, imperative names. “Command” felt more dynamic than “Request” or “Operation.” The pattern’s canonical use case — undo/redo — maps elegantly onto the military metaphor of orders that can be countermanded, which may explain why this particular name stuck.

References

Related Mappings