MVC modeThe application in programming is a great idea."Model" can encapsulate the data related to the business logic of the application and the processing method of the data;"View" can realize the purposeful display of data;"Controller" can play an organizational role at different levels and control the process of the application.
However, you may get confused in the process of using this three-tier architecture model.Because you don't know where to put a lot of code, you have to put it in the control layer. Finally, you find that there is too much code in the control layer.
LinkedIn Software EngineerConrad IrwinHe also encountered the same problem, so he began to use another mode:MOVE,That is, Models, Operations, Views, Events.
Conrad Irwin recentlyPersonal blogShared some views on this model.
summary
Irwin first gives a simple definition of MOVE mode in combination with the figure above:
Models,Encapsulates everything you know about the application;
Operations,Encapsulates everything the application needs to do;
Views,Help users interact with applications;
Events,Used to securely connect all these components.
In order to avoid spaghetti code, the figure shows which types of objects are allowed to operate.For example, views allow listening to events generated by the model;Operations allow you to modify the model, but the model should not involve views or operations.
Models
Here we take a "User" object as the prototype. It has at least one email address, and may also have a user name and phone number.
Only knowledge is packaged in a MOVE model.This means that in addition to the Get and Set functions, they can include such methods as checking whether the user's password is correct, but they will not include such functions as saving the password to the database or passing it to external APIs, because Operations will complete these tasks later.
Operations
For applications, a common operation is user login.This is actually composed of two sub operations: first, obtain the email address and password from the user, then load the "user" model from the database and check whether the password matches.
Operations is an actor in MOVE mode.It is responsible for modifying the model, displaying the correct view at the correct time, and responding to events triggered by user interaction.In a well decomposed application, each sub operation can run independently.
The operation in this way is very exciting, that is, after the program is started, the entire application itself can be regarded as an Operations.It generates as many sub operations as needed, each of which runs in parallel.When all sub operations are completed, the program exits.
Views
The login page is a view, which is responsible for displaying some text boxes to users.When the user clicks the "Login" button, the view will generate a "loginAttempt" event, which contains the user name and password entered by the user.
The content that users can see and the interaction they can feel are supported by views.They will present application feedback in a form that users can understand, and they can also transform simple user interaction into meaningful events.More importantly, views do not directly change the model. They just send events to Operations, and then wait for events sent by the model through listening.
Events
When the user logs in, the view will initiate the "loginAttempt" event.After the login operation is completed, the "currentUser" model will send an event to notify the application that the login status has changed.
Event monitoring enables MOVE (and MVC) to implement inversion of control, allowing the model to update the view.This is a powerful abstraction technique that allows components to be coupled together without interference.
Why now?
Of course, Conrad Irwin does not want to be considered as suggesting that MVC mode is poor. This large-scale application architecture has been very successful in the past decades.However, several decades later, new programming technology has become more and more popular, so you will gradually have some doubts in the use process.
MVC mode is really great, but it was designed for old technology decades ago after all.MOVE mode is an upgrade based on it, so that you can make better use of the existing new tools.
But the end of closed source must be open source, because many people who are dissatisfied with closed source have created open source, so the end of open source is not necessarily closed source, but to find a business model that is open source=Free Admission
I'm laughing to death. Those who have been deeply kidnapped dare not pay?Who will use the domestic open source framework of small companies in the future will be 213!!!Wait for harvesting later
I suggest that 360 open source all its products, and then become the leading enterprise in the domestic open source industry through open source, leading everyone to compete with foreign enterprises
My technical article was moved by CSDN. Why didn't anyone step on the sewing machine? This kind of report is a joke to me. The monsters with background are fine, and the monsters without background fight to death
I give you six seconds. I give you six moves with the same effect in the martial arts contest, which shows the invincibility and confidence of the master
Buddhism has a good word, evil opinion.In dealing with the world, it is meaningless to draw conclusions from preset positions;It is also important to receive good logic training.
That's too right.Old Zhou can't control Google, but he can control 360.Do not do to others what you do not want.All 360 products should be opened first.
Although France is the parent community, the core developers of OCCT on github are all Russians. Without Russians, the French parent community cannot continue to operate.So Huawei took over, moved to China, changed its name and resumed open source and community operations. What's the problem?
The world only knows that Android was created by Google. Several people know that Android is only a product acquired by Google. Similarly, what is the problem with Huawei's contribution to the collection of OGG open source work and integration into its own proprietary product line?
Wine runs the Android emulator of Windows. Chrome OS is installed in the Android emulator. Linux environment is installed in chrome OS. Linux environment is installed in the Linux environment. Wine is installed in the Android emulator
This is also called floor washing?Does it mean that Tesla will not wash the floor if it releases all the source code?Some people HWptds?That is to say, the language is ambiguous, which will also rise to the washing ground?Are some people too focused?Think the people he pays attention to must be staring at?