The Command design pattern provides a solution:
Encapsulate a request
in a separate Command object.
A class
delegates a request to
a Command object
and doesn't know (is independent of)
how the request performed.
Describing the Command design in more detail is the theme
of the following sections.
See Applicability section for all problems Command can solve.
Command objects:
Command | execute()).
Command1,…)
that implement the Command interface.
receiver1.action1()).
Invoker) delegates the responsibility for
performing a request
to a Command object
(command.execute()).
Command object, which it uses to perform a request,
and even more,
the Command object can be
exchanged dynamically.
Background Information