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.
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:
publicclassFish{...}
Interface Names
Interface names should be adjectives. They should end with “able” or “ible” whenever the interface provides a capability; otherwise, they should be nouns. Interface names follow the same capitalization convention as class names:
publicinterfaceSerializable{...}publicinterfaceSystemPanel{...}
Method Names
Method names should contain a verb, as they are used to make an object take action. They should be mixed case, beginning with a lowercase letter, and the first letter of each subsequent word should be capitalized. Adjectives and nouns may be included in method names:
publicvoidlocate(){...}// verbpublicStringgetWayPoint(){...}// verb and noun
Instance and Static Variable Names
Instance and static variable names should be nouns and should follow the same capitalization convention as method names:
privateStringwayPoint;
Parameter and Local Variable Names
Parameter and local variable names should be descriptive lowercase single words, acronyms, or abbreviations. If multiple words are necessary, they should follow the same capitalization convention as method names:
public Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access