What is the Action Design Pattern?

You're right, action pattern == command pattern. You hear it called the action pattern more often in GUI design, in the form "on some button pressed, perform this action". In the code the button would be wired up with an action object of some kind.


I'm reading "The Action/Executor Pattern" at MSDN right now, and I have to disagree with the premise that the Command and Action/Executor patterns are the same.

From the description of the Command Pattern at SourceMaking.com:

  • Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations.
  • Promote "invocation of a method on an object" to full object status
  • An object-oriented callback

From the MSDN article about the Action/Executor pattern:

The Action/Executor pattern identifies a strategy for mapping use cases to code, allowing better visibility and agility. Also, it addresses the issues of contaminating entities and skipping over proper use of transactions.

The difference appears to be that an "action" encapsulates one or more steps, that when performed successfully delegate control to another object responsible for knowing how to persist those changes to a database, web service or file storage. The action is decoupled from how it is executed/persisted.

A "command" feels like one half of the Action/Executor pattern - the "action" seems synonymous with a "command". The Action/Executor pattern takes things one step further and describes another concern whose responsibility is to take the changes generated by the "action" or "command" and save them some place.