O'Reilly logo

Learning Python Design Patterns by Gennadiy Zlobin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required