Summary
In this chapter, we covered the command pattern. Using this design pattern, we can encapsulate an operation, such as copy and paste, as an object. Using this pattern, we can execute a command whenever we want, and not necessarily at creation time, while the client code that executes a command does not need to know any details about how it is implemented. Moreover, we can group commands and execute them in a specific order.
To demonstrate command, we implemented some basic file utilities on top of Python's os
module. Our utilities supported undo and had a uniform interface, which makes grouping commands easy.
The next chapter covers the Observer pattern.