Chapter 20
The Command Pattern
The command pattern provides a mechanism by which details of how to invoke a method can be encapsulated so that the method can be invoked later or by a different component. Table 20-1 puts the command pattern into context.
Table 20-1. Putting the Command Pattern into Context
Question | Answer |
---|---|
What is it? | The command pattern is used to encapsulate details of how to invoke a method on an object in a way that allows the method to be invoked at a different time or by a different component. |
What are the benefits? | There are lots of situations in which using a command is useful, but the most common ones are supporting undo operations and creating macros. |
When should you use this pattern? | Use this pattern when you want to allow ... |
Get Pro Design Patterns in Swift now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.