android-Programming SpecificationA catalog specification
System catalog Specification
Requriement Requirements Related Documents
Design
Planning&log Plan-Log-conference
Help
Source or SRC Code and unit tests
Deployment Release-Deploy-public
Test integration testing-system test-Test report-buglist
Study study materials-demo, etc.
Readme.txt or ReadMe.txt contains the specific meaning of the directory structure
Source Code Catalog Specification
Directory is package-package
directory under which all classes are said with this space, a main class one file
Directory hierarchy recursion
General System namespace directories try not to exceed 3 levels
Namespace: Organization name-project name-module name Chengzhi.android.demo
Two code naming conventions and styles
Common naming conventions
Pascal name Law
First Letter all uppercase: int MyAge; Commonly used in Delphi
Camel Name Method
First first letter lowercase, followed by uppercase: int Myage;java common
Hungarian Naming Act
Preceded by an identifier: String strmyname; VB6 Common
Underline naming method
Underlined by an identifier: String s_myname;
The above naming methods are used, but are not fully used, the following are the various use cases
Package (namespace):
All lowercase Chengzhi.android.demo
File naming: Pascal nomenclature-the first letter of each word is capitalized, the file name is the class name
Class naming
Common class: Pascal
public class SomeClass
{
Public SomeClass () {}
}
Custom attribute classes: Pascal, suffix using attribute
public class Testattribute extends Attribute
{
}
Custom Exception class: Pascal, suffix using exception
public class TestException extends Exception
{
}
Type passing in generics: pass-type letter uppercase
public class testlist<k, t>
{
}
Method Name:
Method name is verb phrase
The common method uses camel naming
Constructors are named by Pascal
Interface naming:
testinterface, suffix plus interface
Event Interface Definition: Onclicklistener
Variable naming
Private member variables:
Pascal name + prefix m private String mmyname
Static member variable Pascal name + prefix s static String smyname
Local variables:
String MyName;
Recommended ways to optimize local variables
String _myname preceded by an underscore
Optimization method Parameters:
String pmyname preceded by P, is the first letter of the parameter parameter
Variables in the loop:
I j K can use meaningless letters
Three-named formatting
Strict line break:
A semicolon, a line break,
Recommended Use
public void Testdemo ()
{
}
This way of curly braces
Strict indentation:
Indent the four cells, or use the TAB key, but tab to set the indent to 4, and indent to
Strict comments:
File, class, method, method parameter, variable, attribute are all to be commented
Comments for files and classes should contain the following elements
Name,description, Version, Date, Author, change, Copyright
Compliance with JAVADOC standards
/**
* First Class
*
*/The way
Select the method or class you want to annotate, and the mouse cursor points above
Then quickly generate the comments above using shift+alt+j in eclipse in Windows
In Mac, it's cmd+shift+j.
Variable takes
My name
Private String Mname
Location of the declaration:
All frameworks define namespaces for a group, custom and third-party namespaces are placed in another group,
All member variables should be declared at the top while using a blank line to enter them and attribute and method separate
Local variable declarations are placed at the top of the method
Declaring a variable with a Java predefined type and not a class name
Use object instead of object
Use int instead of Int32
Four Code Logic specification
1 Avoid placing multiple classes in the same file, unless you are an internal class
21 methods do not exceed 35 lines in length
3 Try not to modify the machine generated code
4 Final string supersedes string, same as int
5 It is not recommended to return using return in the loop
6 Try not to use Goto
7 considering anomalies everywhere
8 Use public when the external ministry is required, the rest use private and internal
9 try not to provide public and protected programmer variables, use attributes instead
10 do not write code directly on a function that is automatically generated by the system, preferably by using a custom function, and then calling
11 Always use interface, it is recommended to use display interface to implement
12 always have default words in the switch statement to display the information
Android-Programming Specification