Defined:
Command mode, which encapsulates a request as an object so that you can parameterize the client with different requests;
Queue or log request logs for requests, and support for actions that can be undone.
Role:
First, it can design a command queue more easily;
Second, in the case of need, it can be easier to complete the command into the log;
Third, allow the party receiving the request to decide whether to request it;
Finally, the cancellation and redo of the request can be realized easily;
The addition of the new specific command class does not affect the other classes, so it is easy to add new specific command classes.
Key advantages: The command mode is to request an action object with an object that knows how to perform an operation to split the grill.
Agile development principles tell us not to add guesswork-based, physically unwanted functionality to your code.
If it is not clear whether a system requires command mode, it is generally not urgent to implement it, in fact, it is not difficult to implement this mode by refactoring when needed, only when it really needs functions such as undo/redo operations.
Refactoring the original code into a command pattern makes sense.
Design mode--Command mode