Chapter 1. Naming Conventions
Naming conventions are used to make Java programs more readable. It is important to use meaningful and unambiguous names comprised of Java letters. The following examples are from various Java sources.
Acronyms
When using acronyms in names, only the first letter of the acronym should be uppercase and only when uppercase is appropriate:
// e.g., DNA is represented as DnapublicclassGliesianDnaProvider{...}// e.g., Most Recent Common Ancestor (MRCA) is MrcapublicclassMrcaCalculator{...}
Annotation Names
Annotation names have been presented several ways in the Java SE API for predefined annotation types, [adjective|verb][noun]:
@Documented@Retention(RetentionPolicy.RUNTIME)@Target(ElementType.TYPE)public@interfaceFunctionalInterface{}
Class Names
Class names should be nouns, as they represent “things” or “objects.” They should be mixed case (camel case) with only the first letter of each word capitalized, as in the following:
publicclassAirDensityCalculator{...}
Constant Names
Constant names should be all uppercase letters, and multiple words should be separated by underscores:
privatestaticfinaldoubleKELVIN=273.16;privatestaticfinaldoubleDRY_AIR_GAS_CONSTANT=287.058;privatestaticfinaldoubleHUMID_AIR_GAS_CONSTANT=461.4964;
Enumeration Names
Enumeration names should follow the conventions of class names. The enumeration set of objects (choices) should be all uppercase letters:
publicenumMeasurementSystem ...