Take notes on learning ASP. net mvc Framework-MVP, mvc-mvp
1.2.1 MVP
MVP is a UI architecture that is applicable to event-driven application frameworks. In MVP, M and V correspond to the MVC Model and View respectively, while P (Presenter) replaces Controller.
In MVP mode, only the Presenter can directly interact with the Model, and the View can only indirectly call the Model through the Presenter. The independence of the Model is truly embodied here. It is not only irrelevant to the presentation of visualization elements, but also to the UI processing logic (Presenter.
MVPs not only avoid the deep coupling between views and models, but also further reduce the Presenter's dependency on views. Presenter depends on an abstract View, that is, the IView interface implemented by a specific View. The most direct benefit of this is that it makes the UI processing logic defined in the Presenter easy to test. Since the Presenter's dependency behavior on the View is defined in the IView interface, we only need a Mock View that implements this interface to test the Presenter.
The interaction between the Presenter and the Model is clear. It only shows that the interaction between the one-way call View and the Presenter of the Model is the core of the entire MVP, whether MVP's original intention for separation of concerns can be reflected in specific applications depends largely on whether the interaction between the two is correct. MVP members are divided into PV (Passive View) and SC (SuperVising Controller) modes based on the interaction mode between View and Presenter and the responsibility scope of View.
1. Rules for PV interaction with SC2.View and Presenter (for SC Mode) 3. Example demonstration: Application of SC Mode