Java naming agreement
In addition to the following special examples, naming should always adopt a complete English descriptor. In addition, lowercase letters should generally be used, but the class name, interface name, and the first letter of any non-initial word should be capitalized.
1.1 General Concept
Try to use the full English descriptor
Terms applicable to related fields
Using upper and lowercase mixing makes the name read
Try to use less abbreviation, but if used, you should use it well, and unified throughout the project.
Avoid using long names (less than 15 letters is a good idea)
Avoid using similar names, or just use different names
Avoid using underscores (except static constants, etc.)
1.2 demonstration
Package adopts a complete English descriptor, which should be composed of lowercase letters. For global packages, turn your Internet domain name and connect to the package. Java.awt, com.ambysoft.www.Persistence
Class (Class) adopts a complete English descriptor, all the first letters of all words. Customer, Savingsaccount
Interface (Interface) adopts a complete English descriptor instructions for interface packages, all words of all words. It is customary, the name is added to the suffix Able, Ible or ER, but this is not required. Contactable, Prompter
Component / Components Use full English description to illustrate the use of components, and the end should be connected to the component type. Okbutton, Customerlist, FileMenu
Exception is usually an abnormality using the letter E. e
The class variable field uses a complete English description, the first letter lowercase, the first letter of any intermediate word. Firstname, Lastname
Naming Rule of Command / Parameter with Field / Properties Public Void SetFirstName (String Firstname) {this.firstname = firstname;}
Local variable naming rules with fields / attributes
Gets the member function to be accessed in front of the prefix Get. Getfirstname (), getlastname ()
Boolean Acquisition Member Functions All Boolean Get Functions must be prefixed with word IS. ISPERSISTENT (), ISSTRING ()
Set the member function to the front plus prefix set in front of the field name. SetFirstName (), setlastname (), setWarpspeed ()
The ordinary member function uses a complete English description description of the member function function. The first word uses a vivid verb as much as possible, the first letter lowercase. OpenFile (), addaccount ()
Static Final All uses uppercase letters, and the words are separated by underscore. Min_balance, default_date
Cycle counters are usually acceptable by alphabetics I, J, K or Counter. I, J, K, Counter
Array arrays should always be named: ObjectType []. BYTE [] BUFFER