Android design mode-appearance Mode

Source: Internet
Author: User

Android design mode-appearance Mode

Problem: In Android, Apk can have the plug-in UPDATE function, represented by QQ;

The problem is that the main system (let's say it) calls the plug-in-installed subsystem, which provides external access to the subsystem. Does it belong to a different appearance mode?

 

First, let's talk about the design model:

1. Definition:

Provides a unified interface for a group of interfaces in the subsystem;

The Facade mode defines a high-level interface, which makes this subsystem easier to use.

2. Purpose:

Reduce the complexity and dependency on subsystems. This makes subsystems easier to use and manage.

Improve code quality, code maintainability, and scalability.

 

3. Design:

At the beginning of the design, we must consciously separate two different layers, and establish a Facade between the layer and the layer,
Adding a Facade can provide a simple interface to reduce dependencies between them.

 

In Android programming, We can consciously strictly separate data access from the business logic layer, so that the design is less coupled.

Especially for subsystem maintenance, the appearance mode is particularly important when subsystems become larger and larger!

 

4. Simple demo:

The first is subsystem:

 

Package com. example. demo. facade;/*** subsystem design * @ author qubian * @ data June 9, 2015 * @ email naibbian@163.com **/public abstract class Lottery {protected abstract String getLotteryName (); protected abstract String getLotteryNum (); protected abstract String getRandomNum ();} package com. example. demo. facade; public class SSQLottery extends Lottery {@ brief String getLotteryName () {return "SSQ" ;}@ response String getLotteryNum () {return "3" ;}@ Overrideprotected String getRandomNum () {return "6" ;}} package com. example. demo. facade; public class DLTLottery extends Lottery {@ brief String getLotteryName () {return "DLT" ;}@ response String getLotteryNum () {return "1" ;}@ Overrideprotected String getRandomNum () {return "7 ";}}

 

Then there is Facade and usage:

 

Package com. example. demo. facade;/*** appearance mode * unified external access * @ author qubian * @ data June 9, 2015 * @ email naibbian@163.com **/public class Facade {SSQLottery ssq; public String getLotteryName (String name) {if (name. equalsIgnoreCase ("SSQ") {ssq = new SSQLottery ();} return ssq. getLotteryName () ;}} package com. example. demo. facade; import android. util. log; public class UseFacade {public void use () {Facade facade = new Facade (); Log. I ("TAG", facade. getLotteryName ("SSQ "));}}

The demo seems to be too simple to write. However, the appearance mode is indeed quite a lot of, and relatively simple;

 

According to my understanding;

In a sense, it seems simple to understand plug-in-type installation as an appearance mode, and the definition is too simple,

The purpose of plug-in installation is to start the sub-system. In addition to the calling sub-system, the main system rarely calls the internal method of the sub-system. Of course, this situation is not ruled out,

If yes, it does not meet the plug-in-type installation and update purposes; so there is indeed no solution.

The problem is left here first.

 

 

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.