Advantages and disadvantages of the Command design pattern
The pros and cons of the Command design pattern are as follows:
- It is useful when creating a structure, particulary when the creating of a request and executing are not dependent on each other. It means that the Command instance can be instantiated by Client, but run sometime later by the Invoker, and the Client and Invoker may not know anything about each other.
- This pattern helps in terms of extensibility as we can add a new command without changing the existing code.
- It allows you to create a sequence of commands named macro. To run the macro, create a list of Command instances and call the
execute method of all commands.
The main disadvantage of the Command Pattern is the increase in the ...