Command mode, or similar mode. I personally think it is a C ++ or Java style, but it does not mean that these modes are not required when VB or Windows form is used for programming.
The core idea of the command mode is to make the Interface ClassCodeSeparated from the Action Code, for example, the code for creating a menu (not an applicationProgramCall the class that creates a menu, but a menu class), and there is no specific operation code in its action (click) code. How can this problem be achieved? There is a reference to the command interface in the menu item class. Its click process calls the execute method of this command. The specific command object is bound by the app class (For details, refer to the gof design mode ).
This is basically not required for VB or Windows form development, because through the event mechanism, interface operations and actions can be implemented in their events. The interface components have been designed. You can process the action code in the corresponding event handler. However, for some requirements, you still need to use the command mode to do something.
For example, you can use the command mode to record user actions, determine whether the operation has the permission, or add undo to the operation (the classic command mode is required. In command mode, this type of code is isolated from the interface form. For example, you can use the following code in a button-click event:
_ Testcommand. Execute (...)
In this command implementation, you can check permissions and record actions.
In addition, for some actions triggered by events, you can also use command to implement specific actions and remove the specific operation code from the form.
In VB 6, the author basically uses the creation of a series of command processes in the module to perform operations. I personally think that the idea of command is to isolate interfaces and actions. Bob's Agile Software Development contains an example of a photocopier application.