Answer the question
In order to leave comments, you need to log in
What is the difference between MVC and MVP?
Many words have already been said about this, but the salt from all comparisons cannot be taken out. I ask you to help me deal with specific questions:
"In MVC, the controller chooses which view will be displayed. In MVP presenter, it simply updates the view with new data."
1) Correctly, I understand that the controller directly injects / removes DOM nodes, thereby managing the displayed view. Would the router example work in this case: controller renders different pages depending on the path change?
Answer the question
In order to leave comments, you need to log in
The difference between the approaches is how the user commands and handlers are linked .
MVC - when the user gives commands not to the View, but to the controller (i.e. View has no logic as such)
(example = ASPX: static html page is View, and http requests go to the controller (on the server))
MVP - when the user interacts with the View, and the View interacts with the Presenter directly.
(example=winForms: the form is a View, when the button is clicked, the code from Form.cs(Presenter)
MVVM is called - when the user interacts with the View, and the View interacts with the VM through bindings
(example=WPF: form is a View. when a button is pressed, interaction with the code occurs through bindings)
At least that's how I understood it :)
Regarding your question: both Controller and Presenter change the view. The difference is that in the first case, the view does not interact with the Controller in any way (ajax does not count), and in the second it interacts directly.
I can assume that if the site has ajax that connects the view to the controller, then this is no longer MVC, but MVP.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question