MVC consists of three roles: model, view, and controller. The model represents the specific data and behavior. The view represents the data display. The controller obtains user operations, changes data, and controls the view display. Its core lies in separating the view from the model and the controller from the view.
For Windows formProgram(VB 6 is similar). The controller is basically a built-in form and various components (Controls) of the system, and does not need to be written for user operations.Code, You only need to write the specific operation in the code of the Action event response.
It is a model design. It is generally a class or a group of classes that have specific data and operation code.
For data display, that is, a view, it can be a method, a group of methods, or a class. The key lies in data refresh. There are two methods:
First, define some events in the model to update or change the data. subscribe to these events in the view and write the specific view update code in the event trigger method;
Second, call the method or class for refreshing data display in the code after the action is completed to change the view;
The first method of personal preferences is that the program on the Web must use the second method. In this way, the model class is more pure. However, it seems that it is not good for the form program to update interface data when something is okay, it is also difficult to save the user status, such as the selected data (table. In addition, the final update data of an operation sometimes requires context and is uncertain. It seems easy to control and encapsulate data through event triggering.
Although most of the Windows form programming can be completed without the need to pay attention to the MVC role, I personally think it is worthwhile to learn something from it to improve the program design and code quality.