Confused about MVC and MVP patterns
PHP中文网
PHP中文网 2017-05-16 17:06:38
0
3
533

I recently read an article about MVP. It is quite simple. It just introduces what the MVP model is.

But the difference between MVC and MVP is really not clear. After reading it, I feel that "MVP is just MVC with stricter specifications."

What role does the Presenter in MVP play?

I checked some information about MVP. It is said that compared to the Controller in MVC, the Presenter has an additional function of fully separating the Model and View. But in fact, in my concept (in daily applications), the Model and View in MVC can be separated. In my normal development, I process the data provided in the Model in the Controller and then render it to the page. In other words, MVC can actually separate V and M in many cases. So, what is the purpose or point of proposing the MVP model?

I hope you can give me your opinion, thank you!

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(3)
世界只因有你

I firmly believe that there are no bad questions, only bad answers.


At first, there was only the command line.

The soul of a software engineer runs on the shell.

Xerox said: "There needs to be a GUI"...

1. MVC for desktop software

Thanks Smalltalk. Thanks to the GUI.

2. MVC with B/S architecture

Later, with the rise of the Internet, programmers put their programs to run on the server. At this time, the GUI changed. The reality of all interfaces (View layer) is replaced by the browser (HTML).

At this time, MVC was brought to the BS architecture. Thanks sun. Thanks struts.

3. Front-end MVP

Later, browsers became more and more powerful, so many businesses were executed in browsers.

So programmers brought MVC to the View layer. However, using HTML+CSS+JS as the display layer is very different from the traditional desktop GUI. Therefore, in order to give full play to the characteristics of the js language, MVP appeared.

为情所困

Comparison of Architecture presentation patterns MVP(SC),MVP(PV),PM,MVVM and MVC

[Translation] MVP(SC), MVP(PV), PM, MVVM and MVC performance model architecture comparison

黄舟

The evolution of architecture:

MVC mode:
View <-> Controller <-> Model; Controller is not only responsible for routing, but also for the connection between the business layer and the presentation layer. It can flexibly configure functions in the controller during development. It is not as intuitive as MVP during development, and it is more concise in MVP which has less focus.

MVP mode:
View <-> Presenter (Controller <-> Events) <--> Model; Presenter hides the routing and controller parts, so that development does not need to worry about the routing and control layer of the message. Put it into the event triggered by each message, and perform business operations in the event. It makes development simpler and more intuitive, but sacrifices the flexibility of controller layer operations.

MVVM mode:
View <-> ViewModel <-> Model; ViewModel can not only serve as the Presenter function in MVP, but ViewModel can actively update View. Instead of a single background update triggered by View. It can be said that MVVM is an enhanced version of MVP

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template