Five years ago, when PHP was still hot, the community was full of PHP articles ... Almost every month there is a new framework to produce and claim to amputated everything, and then every month the framework is closed ...
Suddenly one day the weather changed, PHP is not the world's best language, now py and Golang on fire up ...
The react, vue, angular, and the front wheel are discussed throughout the community. It is also the state that almost every new wheel produced is claiming amputated everything, and then ... And then it went bankrupt. 2333
At the same time, MVVM is discussed and hyped ...
I personally wrote the MVC and MVVM sites, and I think it's really simple to look at the two patterns in a straightforward way.
First, what is MVC and MVVM?
Frankly speaking, is the literal meaning, one is Model+view+controller, one is Model+view+viewmodel
It's purely literal, what can be explored ...
What do these literally mean, model operations databases, view control views, controller responsible for business logic, or ...
Model operations database, ViewModel operation to the View rendering data (interface), view is responsible for rendering ...
It is just so straightforward ... What do you not understand?
Then, what are the pros and cons?
The advantage of MVC is that the view layer is very thin, but also very traditional, front-end almost only need page reconstruction, the back-end workload is a little bit ...
And incredibly simple, do not think about the interface, or even PHP set up a environment to finish the child ...
The drawback of MVC is that the controller is too heavy, responsible for almost all of the business logic, and in such a heavy case, can hardly be reused, not quite in line with engineering ideas ...
Then the front end of the job is too little, no way to raise wages and forced ...
The advantage of MVVM is that the business logic can be handled by the front end, can be split components, can also be installed to force a pay rise, it seems to appear more in line with the mainstream of the components, engineering ideas ...
The disadvantage of MVVM ... Is the complexity of engineering, such as we do a PC-side, mobile, and back-end of the full stack site, plus back-end and database, need to open five interfaces at the same time! Five Consoles!
If a person comes to write ... It's more tragic ... The company also division of labor with:: >_<:: A man should despair ...
Above...... is the pros and cons, but also very straightforward, really do not have anything to say ... Forgive me for the number of words:: >_<::
Finally, how do you treat these two patterns correctly?
In fact, both are more mature models, straightforward to say, when you a person full stack, write a personal blog What, MVC is undoubtedly very provincial (if your backend base is OK), efficient √
But if in the company, you as a front-end personnel (such as me), is very expected to MVVM, not to mention the increase in the Force, just as a toss pot, it is very convenient ...
Anyway, just get the interface and you can do whatever you want, right? (⊙o⊙) ...
Above...... Say the upright white, we do not care, and then do not have MVVM superior, despise the situation of MVC ... In fact, these two things are literally meant to be converted in a second ...
MVC and MVVM