MVC model in Android (composite mode)

Source: Internet
Author: User

MVC is an acronym for Model,view,controller, and MVC consists of three parts:

1. Model object: Is the main part of the application, and all business logic should be written on that layer.

2. View object: Is the part of the application that is responsible for generating the user interface. It is also the only layer that the user can see in the entire MVC architecture, receiving input from the user and displaying processing results.

3, controller (Control) object: is based on user input, control user interface data display and update model object state of the part, controller more important a navigation function, want to use the user to start related events, to M processing.

Android encourages weak coupling and component reuse, and the detailed embodiment of MVC in Android such as the following:

1, view: Generally adopt XML file for the description of the interface, the use of the time can be very convenient to introduce, of course, how you know more about Android, you will be able to think of Android can also use javascript+ HTML and so on as the view layer, of course, there is a need for Java and JavaScript communication between, fortunately, Android provides a convenient communication between them implementation.

2, Control layer (Controller): The task of Android control layer usually falls on the shoulders of many acitvity, this sentence also implies do not write code in acitivity, to through activity delivery model business Logic layer processing, Another reason for this is that the response time of the acitivity in Android is 5s, and the program is very easy to recycle, assuming time-consuming operations are put here.

3, Model: the operation of the database, the operation of the network should be processed in the model, of course, business computing and other operations must be placed in the layer.

MVC is a composite pattern that may include policy patterns, observer patterns, combinatorial patterns, singleton patterns, and so on, which are designed to understand decoupling and make programs easier to maintain and extend

MVC model in Android (composite mode)

Related Article

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.