The traditional MVC pattern

Source: Internet
Author: User

For the MVC pattern, we can make visual UI rendering, UI processing logic and business logic defined separately in View,controller, and model.

Visual UI Rendering->view

UI processing Logic->controller

Business logic->model

In the MVC pattern, the interaction between the three is not strictly limited, and the analogy allows the view and model to interact directly

Variant of the MVC pattern MVP

MVC is a very broad concept that does not set a strict rule between view,controller,model. So for a specific development framework such as (ASP. NET Web Form), there is a variant of the MVC pattern.

in ASP. NET Web form, the MVP's M and V correspond to the model and view in MVC, and P (Presenter) replaces the controller. The MVP changes are reflected in the interaction between the three.

In the MVP, the only presenter,view that can interact directly with the model is that only the model can be called by presenter. The model remains independent here, regardless of the rendering of the visual element (View), regardless of the UI processing logic (Presenter)

The MVP avoids the coupling between the view and the model, further reducing the dependency between the presenter and the view. Presenter relies on a iview interface, which is the interface iview the view implements.

The interaction between MVP three elements is mainly embodied in two aspects, namely View/presenter and Presenter/model. Between presenter and model, just a single call to the model is presenter. The core of the whole MVP is the interaction between view and presenter. Based on the interaction between view and presenter, and the role of view, the MVP is divided into two modes: PV (Passive View) and SC (supervising Controller).

The PV (Passive View) mode, which is a passive view,view, does not involve any UI processing logic, and all actions for UI elements (controls) are not controlled by the View itself, but are referred to presenter to control

Using the PV mode to implement view, we need to expose the UI elements in the view through the shape of the attributes. Specifically, when defining the IView interface, you need to define a UI element-based interface, which is presenter to fine-grained the view. Ideally, you define UI element properties for the iview interface, which should be platform agnostic and not directly defined with the control type. In PV mode, all UI processing logic is defined in presenter, and the members of the interface iview become much more.

The-->SC mode reduces the complexity of presenter and transfers simple UI logic to the view, which is defined in the IView interface. For the view operation, the view itself does not correspond, but instead forwards the request to presenter. The presenter drives The view or creates the view for the model call.

MVC in ASP.

ASP. NET MVC is a Web application framework built on an ASP. NET platform based on the MVC pattern.

The custom IHttpModule intercepts the HTTP request, resolving the Controller and action of the target request.

Custom Ittphandler to activate the target controller.

The model in ASP. NET MVC is only data that is bound to the view, and does not contain any UI logic code. The model is based on view only, or it can be called a view model. The MVC pattern used to build ASP is understood as M (Model)-V (view)-vm (view Model)-C (Control)

The traditional MVC pattern

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.