Android Codereview a bit summary

Source: Internet
Author: User

Codereview a bit of summary

1: Use Handler.post (Runnable) when using handler, Hanler to keep weak reference relationships with classes, or use static handler objects

Public Handler h = new Handler () {//is not recommended        @Override public        void Handlemessage (Message msg) {        }    };
<pre name= "code" class= "java" >public static Handler h = new Handler () {//recommended        @Override public        void Handlemes Sage (Message msg) {        }    };
H.post (..); /recommended

2:integer types and Enum types

When there are multiple cases of return values, the recommendation is to use Enum to judge. Instead of returning int type data! If you need to use the int type, you also need to encapsulate int into one socket for unified management

3: A small way to do only one thing, such as:

public void Update () {aa.update ();}
Do not appear:

public void Update () {aa.update ();
Bb.xxx ();}
Keep Code method names consistent with what you do


TODO Next Add



Android Codereview a bit summary

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.