Strict line break
In General the next one ";" a line break
One row for the suggested function "{}"
Example:public void oosomething ()
{
......
}
Do not use:
Example:public void dosomething () {
....
}
In fact, both ways can be, here do not make mandatory provisions.
It's best to use the first way, because it's also handy in this way in eclipse.
Strict indentation
Use Tab Indent
Annotation indentation and Code indent alignment
Strict comments
File, class, method, method parameter, variable, attribute are all to be commented
Each variable that has a meaning is written in a comment.
Comments for files and classes must include the following elements:
Name,Description,Version,Date,Author , Change , Copyright
The main point to Remember is " follow the javaDoc standard ".
Example:/**
*/
The variable comment is written in front of //on it .
Cases:
this is my name.
/**
*/
Private String Mname; //
This is not necessary, very troublesome, directly with a single-line comment.
There are comments are not recommended to put the back, put in front will be very neat.
Location of the Declaration
Apply namespace Location
All frameworks define namespaces as a group, and custom and third-party namespaces are placed in another group.
Import COM.ANDROID.INTERNAL.R;
Import Com.android.internal.view.menu.MenuBuilder;
Import Android.content.Context;
Import android.content.res.Configuration;
Import Android.content.res.TypedArray;
it 's all about the content.
Import Android.graphics.Bitmap;
Import Android.graphics.Canvas;
Import Android.graphics.Interpolator;
Import Sundy.android.demo;
class member Variable declaration location
All member variables should be declared at the top, using a blank line to separate them from the properties and methods.
public class MyClass
{
int mnumber;
As far as possible in front of the class, do not interspersed to put
String Mname;
public void SomeMethod1 ()
{}
public void SomeMethod2 ()
{}
}
Local variable declaration location (variables in the method set)
Local variable declarations are placed at the top of the method
declaring a variable with a Java predefined type instead of using the class name
Declaring a variable with a predefined type (keyword) without using the class name
use object instead of object
use int instead of Int32
Keywords are preferred using keyword
original link:http://www.maiziedu.com/wiki/android/pattern/
Android naming format