Java Coding Standards & mathematical beauty book review

First, the naming convention

1. The first letter of class names and interfaces word should be capitalized. Fields, methods, and object (handle) the first letter should be lowercase. For all identifiers, which contains all the words should be close together, and the initials middle of a word. For example: ThisIsAClassName, ThisIsMethodOrFieldName.

2. identifier naming requirements Tech, Tech is the identifier can accurately express the significance it represents, and as concisely as possible on the basis of Tech, such as: such as: theOrderNameOfTheTargetSupplierWhichIsTransfered too long, transferedTargetSupplierOrderName is better, but it transTgtSplOrdNm Oh no. Omit vowels Do not use abbreviations, it is best not to use the word abbreviations.

3. The packages are named to all-lowercase letters, and do not use separate characters between words, such as pers.xxx.firsttest, no pers.xxx.first_Test..

4. The method of naming the first letter lowercase, as addOrder () do not AddOrder (); Note that the previous verbs, such as addOrder (), do not orderAdd (), usually a verb prefix have special significance, for example, create (create), add (add ), delete (delete) and so on.

6. static constants, enumeration name is all uppercase, separated by an underscore.

Second, the code specification

1. In a switch block, or in each case terminated by a break / return, etc., or explanatory notes to which the program will continue until the case, within each switch block, it must contain a default statement and placed at the end even if it is what the code does not.

2. Use the Tab key code indentation;

Left delimiter of the block 3. The brace "{" and the closing brace "}" on a separate row, and should each separate line in the same column, while statements that reference them with left alignment; alignment using only the TAB key, not use the spacebar; do not allow multiple short statement written on one line, that line of writing only one statement; if, for, do, while , case, switch, default and other statements from one row.
4. Class, Method, and independent between blocks, after the blank lines must be added to variable declaration; to leave a space after the keyword, then as if, for, while other talk key should leave a space left bracket "(" to highlight the keywords; method name and its left bracket "(" do not include spaces between, in order to distinguish the keyword; binary operators, such as "=", "+ =", "> =", "<=", " + "," * "," % "," && "," || "," << "," ^ " and the like should be added before and after the space; unary operators such as" "," - "," ++! "," - "before and after no spaces; xiang" [] "," " no spaces before and after such operators; for statement expression should be separated spaces; the casts should be followed by a space.

Third, the habit

1. if, execution statement section for, do, while other statements regardless of how much will be added brackets "{}"

2. Whenever execution down along a case (because there is no break statement), add notes normally be the position of the break statement;

3. Avoid configured in a loop and release objects

4. In using local variables, process according to the principle of proximity. It does not allow the definition of a local variable, and then only in far away;

The copy feature does not allow the same codes into N parts;

6. To make full use of StringBuffer class when dealing with a String.

Guess you like

Origin www.cnblogs.com/jewfer-03-08/p/11450527.html