MVC, MVP, MVVM Model Comparison summary (2) Landscape architecture model

Source: Internet
Author: User
Tags eventbus

Preface Description

In the actual combat project and study to summarize the Android Terminal Project framework

Includes MVC, MVP, MVVM, primarily for mobile Android

This article only describes the transverse frame model

Directory

1. Framework Basics

2. Transverse frame model

3. Vertical structure Process

4. Code examples

2. Transverse frame model

MVC Architecture

General Description:

Use Manager as Controller layer

Activity/fragment (view) calls Manager (Controller) to process requests

Manager (Controller) calls NETHELP (model) to process business logic

Dashed lines represent return results

Nethelper network communication using Asynctask+urlconnection implementation

MVP Architecture

General Description:

Presenter receives a view pass interface reference to manipulate the view

Activity/fragment (view) calls presenter processing requests

Presenter Call Nethelper (model) to process business logic

Dashed lines return only to presenter

But presenter through the interface Operation Activity/fragment (view), their arrows bidirectional communication

Presenter can also communicate with activity/fragment (view) via Eventbus or callback

NETHELP network communication can be translated into use okhttp implementation

MVVM Architecture

General Description:

ViewModel with databinding and XML layout files to manipulate raw data directly

ViewModel and Activity/fragment (view) are also bidirectional communication two-way arrows

Dashed lines represent the result returned, returning only to ViewModel

ViewModel must still need to get activity related objects to display for users to view

This can be an environment object in activity or the activity itself

Of course ViewModel can also communicate with activity through Eventbus or callback

NETHELP network communication can be translated into the use of popular Retrofit+rxjava implementations

Summary of the architecture model

1. The model models layer typically includes not only the business logic model, but also the entity model.

Business logic is typically a layer that handles a specific business, such as the dbhelper of all data requests that are processed in this article as this layer

May not be the same at the backend. Backend business model includes service middle tier, DAO data persistence layer

Entities are specially hosted data, such as user entity student, student entity.

2. In terms of architecture, this article is only relatively fixed mode, I think in the condition of having the foundation, can completely without the recruit wins the recruit

Or the old saying, choose the most appropriate framework for your project

For example, I personally feel that the MVP is the standard, so that presenter refers to the view interface

The XML layout is also a root presenter binding, so presenter can manipulate the original data directly, and manipulate the view method

MVC, MVP, MVVM Model Comparison summary (2) Landscape architecture model

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.