The Command Pattern
The Command pattern aims to encapsulate method invocation, requests, or operations into a single object and gives us the ability to both parameterize and pass method calls around that can be executed at our discretion. In addition, it enables us to decouple objects invoking the action from the objects that implement them, giving us a greater degree of overall flexibility in swapping out concrete classes (objects).
Concrete classes are best explained in terms of class-based programming languages and are related to the idea of abstract classes. An abstract class defines an interface, but doesn’t necessarily provide implementations for all of its member functions. It acts as a base class from which others are derived. A derived class that implements the missing functionality is called a concrete class (Figure 9-7).

Figure 9-7. Command pattern
The general idea behind the Command pattern is that it provides us a means to separate the responsibilities of issuing commands from anything executing commands, delegating this responsibility to different objects instead.
Implementation wise, simple command objects bind together both an
action and the object wishing to invoke the action. They consistently
include an execution operation (such as run() or execute()). All Command objects with the same interface can easily be swapped as needed, and this is considered one of the larger ...