Design Patterns in Android

Source: Internet
Author: User

I. Classification of design Patterns

Overall, 23 design patterns fall into three broad categories:

Create five types of models: Factory method mode, abstract Factory mode, singleton mode, builder mode, prototype mode.

Structure mode, a total of seven kinds: Adapter mode, adorner mode, proxy mode, appearance mode, bridging mode, combined mode, enjoy the meta-mode.

There are 11 types of behavioral Patterns: Strategy mode, template method mode, observer mode, iteration sub-mode, responsibility chain mode, Command mode, Memo mode, state mode, visitor mode, mediator mode, interpreter mode.

In fact, there are two types: concurrency mode and thread pool mode.

II. Eight design patterns common in Android

In general, there are eight common design patterns: Singleton, factory, observer, Agent, command, adapter, composition, visitor

Singleton mode: In order to make the system only one call object, the disadvantage is that the singleton makes the other program rely on it excessively, and the different singleton runs in the different process, makes the maintenance difficult;

Factory mode: The production of some fixed things, such as abstract class, the disadvantage is the product modification trouble; If the person likes action movies and love movies to send the same request to the server, they can get the movie set that they want to see, which is equal to the same request from different objects, and needs are satisfied.

Observer pattern: A object is monitored by multiple objects, such as a cache;

Proxy mode: Your own things to others to do, the results can be returned, such as asynchronous threads;

Command mode: Separates the calling object from the object, and the middleware coordinates the work between the two, such as the controller;

Adapter mode: Turns an interface into a user-required interface, such as Baseadapter can be adapted to the ListView and spinner, because they have the same interface

Compositing mode: Converts a one-to-many relationship into a pair of whole relationships, such as a ListView and adapter;

Visitor pattern: Take different treatments for different objects, such as instanceof.

Android Development Design Model series of brocade, very good an article recommended to everyone.

Http://mobile.51cto.com/android-419145.htm

Design Patterns in Android

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.