S
S
Suspense2020-02-10 21:42:45
Software design
Suspense, 2020-02-10 21:42:45

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?

  • 1.1) If so, then it turns out that the controller must have references to instances of all views? For it is said that several views can work with one controller.
  • 1.2) If this is not true, then it turns out that the controller simply updates the data in the rendered view. The presenter also updates the data in the view. What is the difference between controller and presenter then?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Glebov, 2020-02-20
@GLeBaTi

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 question

Ask a Question

731 491 924 answers to any question