[Java] variable naming convention

Java is a language to distinguish between uppercase and lowercase letters, so we define a variable name when to pay attention to distinguish between upper and lower case and some specifications, then we simply say something about the Java language package named classes, variables, etc. specification.

(A) the Package (package) is named

  Package names should be lowercase words are from a composition, such as com, xuetang9, company and so on.

(Ii) Class (class) name

  Class names capitalized, are typically synthesized a class name consists of multiple words, the first letter of each word requirement should be capitalized, such as: XueTang or ProNine.

(C) the variable named

  Variable names can be mixed case, but the first character should be lowercase. Words are separated by capital letters, underlined limit, restrict the use of the dollar sign ($), because this character has a special meaning for the inner class. As an example: idCard.

(D) Interface (Interface) named

  And Class (class) similarly named.

(V) final static variables (or the constant) named

  The final name of the static variables should be capitalized, and pointed out that the full meaning, for example: final MAXUPLOADFILESIZE = 1024.

Naming (six) method

  The first word method name should be a verb, the case can be mixed, but the first letter should be lowercase. Within each method name, in capital letters the word separator and limit its use. Parameter name must match the naming conventions of variables. Use meaningful parameter name, if possible, and use the fields to be assigned the same name: setEvaluate (int size) {this.size = size;}

Naming (g) of the array

  Array should always be named in the following way: String [] name; instead: String name []; worth noting that should as far as possible full English name descriptor. In addition, the general should be used lowercase letters, but the first letter of the class name, interface name, and any non-initial word capitalized.

Boils down to this: try to use a full English descriptor, using terms applicable to related fields, using mixed case to make names readable, minimize the use of abbreviations, but if used, to be used wisely, and uniform throughout the project avoid using long names (best to keep not more than 15 letters), but also to avoid the use of a similar name, or just different names case, avoid using the underscore (except for the static constant, etc.).

Guess you like

Origin www.cnblogs.com/zengzi233/p/12116935.html