MVP personal understanding 2

Source: Internet
Author: User

Based on my understanding, I drew a picture.

 


This time I have read more complex examples.

A project usually has multiple parts. We can divide them into several activities by function. Each activity has its own view and data model, so it also has its own logic presenter ,, assuming that a project can be set up in the M v P mode, the entire project will be very clear, and there will be very little work for every MVP in three aspects, and can write code logically and clearly.

In the previous parsing, the logic should be correct, but not all data is stored by a model. Different data should have different models, such as students and teachers, the presenter and view interfaces are the same. different functions and implementations have different presenter and view interfaces and can be reused. For example, graduate and undergraduate students can use the same template presenter, you only need to change the data of the model. This will reduce repetitive work and reflect the reuse idea.

This time I think it's a bit messy. I don't know how to express it, nor have I learned many other things. I just drew a picture and it will be clearer later .... The following is a summary of others ....


In MVP, the presenter completely separated the model and view, and implemented the basic program logic in the presenter. In addition, the presenter is not directly associated with the detailed view, but interacts with each other through the defined interface, so that the presenter remains unchanged when the view is changed, that is, reuse!

MVP strengths

1. The model and view are completely separated. We can modify the view without affecting the model.
2. The model can be used more efficiently because all interactions occur in one place-inside the presenter.
3. We can use a presener for multiple views without changing the presenter logic. This feature is very practical because views are always changing more frequently than models.
4. If we put the logic in the presenter, we can try these logics (Unit Testing) without using the user interface ).

Disadvantages of MVP

Because the rendering of the view is placed in the presenter, the interaction between the view and persenter is too frequent. Another point needs to be clarified. If the presenter renders the view too much, it will often be too closely linked with a specific view. Once the view needs to be changed, the presenter must also be changed. For example, if the presenter originally used to present HTML needs to present PDF files, the view may need to be changed.

Differences between MCP and MVC

Http://www.360doc.com/content/12/0405/13/8101845_201083284.shtml

MVP personal understanding 2

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.