Summary
The COMMAND pattern lets you encapsulate a request in an object so that you can modify at runtime the method that a client will call. A classic example of the usefulness of COMMAND comes with menus. Menus know when to execute an action but don't know which method to call. COMMAND lets you parameterize a menu with the method calls that correspond to menu labels.
When you use a Java menu you can supply commands into a context that other developers have created. In other cases, you may take the role of the context provider, developing an environment in which to execute commands. Your environment may allow for parameterization of a service, as Java menus do. You may also provide hooks, or add extra value, such as timing an operation.
COMMAND ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access