Browse Java Design Patterns & Enterprise Application Architecture

Command Pattern

Use the Command pattern in Java when requests should be captured as objects that can be queued, logged, retried, or undone.

Command becomes useful when “do this action” should itself become a first-class object.

In Java, that matters when requests need capabilities beyond direct method calls:

  • queuing
  • retrying
  • scheduling
  • auditing
  • undo and redo

The pattern is strongest when command objects carry meaningful intent and lifecycle. It is weakest when a plain method call is wrapped only because a catalog said to do so.

In this section

Revised on Thursday, April 23, 2026