Package, class, interface, enumeration type, parameters, constant fields, methods and exceptions;
1. Naming of packages (package)
The package name should be in full English descriptors, which are made up of a lowercase word. And the prefix of the package name is always a top-level domain,
Usually com, edu, gov, mil, net, org, etc.;
such as: Com.yjhmily.test
2. Naming of classes (class)
The class name should be a noun, in a mixed case, capitalized by the first letter of each word. Try to ensure that the class name is concise and rich in description.
Use full words to avoid abbreviations (unless the project has a uniform abbreviation specification or the abbreviation is more widely used, like URLs, HTML)
such as: filedescription
3, the name of the interface (Interface)
Similar to the naming conventions of Class. On the basis of satisfying the CLASSD naming rules, ensure that the first letter of the beginning is "I",
Easy to distinguish from normal class. Its implementation class name takes the second letter of the interface name to the last, and satisfies the naming specification of the class name;
such as: Imenuengine
4. Enumeration (enum) naming
Similar to the naming conventions of Class. On the basis of satisfying the CLASSD naming rules, guarantee the first letter "E" at the beginning,
Easy to distinguish from normal class.
such as: Euserrole
5. Naming of exceptions (Exception)
Exceptions (Exception) typically use the letter E to indicate an exception, and for a custom exception class, the suffix must be Exception
such as: businessexception
6. Naming Methods (method)
The method name is a verb, in mixed case, the first letter in lowercase, followed by the first letter of the word capital.
The method name describes the action behavior of the method as much as possible. A method that returns a Boolean of type is typically preceded by "is" or "has"
such as: Getcurrentuser (), AddUser (), hasauthority ()
7, the name of the parameter (Param)
The first letter is lowercase, followed by the first letter of the word. The parameter number name does not allow an underscore or dollar sign to start,
Although this is syntactically permissible. Parameter names should be short and descriptive.
such as: Public UserContext getloginuser (String loginName);
8, the name of the constant field (Constants)
Static constants fields (static final) are all uppercase letters, and the words are separated by underscores;
such as: public static final Long FEEDBACK;
Publicstatic Long User_status;
Naming conventions in Java syntax