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

Summary

The Command design pattern provides an interface to call a method to perform some job and encapsulates all necessary information to do it in one object call, which can be run separately and later after instantiation.

The Command design pattern can be used to achieve undo operations if you implement a method that cancels the execute function result.

The Command design pattern can be used to implement the history of executed operations and macros as a set of Command instances, which can be executed in a sequence.

In the next chapter, you will learn about the Template Method pattern that helps you to adjust an algorithm to different contexts with minimal changes.

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