I. Directory specification
1. system catalog Specification
Requirement: requirements documentation; Design: designing documents;
Planning&log: Planning, logging, meeting;
Test: Integration test, System test, test report;
Study: Learning materials, demo, etc.;
Deployment: Release, deployment, etc.;
Source: Code and Unit test;
Help: Related assistance documents;
2. Source Code Directory specification
Directory is a package; All classes under the directory belong to this namespace, one main class and one file;
directory hierarchy recursion; The general System namespace directory is best not to exceed 3 layers;
Two. Code Coding specification
1. Common Naming conventions
Pascal nomenclature (Delphi): The first letter of each word capitalized;
Camel nomenclature (camel name): First letter lowercase, followed by uppercase words;
Hungarian nomenclature (VB): Use prefixes to demarcate features and attributes, such as Mname;
Underline naming method: use underline to divide;
2.Android Naming features:
Package: all lowercase;
File name: The name is the class name;
Class naming: (Ordinary Class) Pascal nomenclature; (custom attribute Class) plus attribute; (custom exception class) plus exception; (generic type pass) K, T;
Method Name: Pascal named for the constructor, camel named for ordinary functions;
Interface naming: General plus suffix naming;
Variable naming: (in Class) Private member variables (mmyname), public variables, static variables (smyname), local variables (camel), method parameters (camel), cyclic variables (meaningless letters);
Optimization: The local variable begins with _, and the parameter variable starts with p;
3. Formatting:
Strictly wrap: A colon in a line; {} a row;
Strict indentation: Use tab indentation, emphasis on indentation and code indentation alignment; strict annotations: Files, classes, methods, method parameters, variables, attributes; Files and classes must contain the following elements: Name,description,version,date,author,change, Copyright;
Declared position: Similar import is put together, can be very clear, member variables in the front, preferably not interspersed to put; Local variables are also placed in front of local methods;
Declaring variables using Java predefined types without using class names;
Third, Code logic specification
1. Avoid placing multiple classes in a single file, except for one-time use of internal classes;
2. The code length of a method should not be more than 35 lines;
3. In principle, try not to manually modify the machine generated code;
4.final string instead of the direct "string", the same as int;
5. Do not perform a direct return operation in the normal loop statement;
6. Do not use goto statements;
7. Consider anomalies, especially I/O operations, and do more try...catch operations everywhere;
8. Use public only publicly, others use private or internal;
9. Try not to provide public and protected program scalars, using attributes instead of them;
10. Do not automatically generate functions in the system directly some business code, preferably custom functions, and then call;
11. Always use excuses, recommend the use of display interface implementation;
12. Always have default words in the switch statement to display the information;
Android Programming Specification Guide