Identifier Naming Practices

Identifier names should carry descriptions of the entities they represent rather than being based on personal preferences. 

It’s helpful to use pronounceable names to make it easier to discuss programs with developers and other collaborators.

Ideally, the length of a variable should be between 10 and 16 characters, neither too long nor too short.    Local variables should have shorter names than global variables. 

Classes and objects should be named with nouns and/or noun phrases, such as ‘customer_Age’ or ‘phone_Number’.  Functions should be named with verbs and/or verb phrases, such as ‘display_Time’ or ‘calculate_Pay’. 

For loops, counter variables are usually i, j, or k. 

Provide meaningful names for status variables to ensure code is comprehensible.

Names given to Boolean variables should suggest that the variable contains either a ‘True’ or a ‘False’.

Use names for constants that are descriptive of their meaning rather than the number they represent.

Use standard abbreviations when available.  Abbreviations should use the first letter of each word, or the first few letters of each word.  Use the same abbreviated name consistently.

Do not create variable names that are similar in pronunciation. 

Avoid mixing numerals with letters.

Do not use programming language keywords as variable names

Avoid frequently misspelled words

Avoid having variable or function names that are too similar to each other.


Writing code includes adding internal documentation in the form of comments.  Comments are notes within the code that explain the purpose of the code. 

It is good programming practice to include a comment header at the beginning of every class or file.  The comment header identifies the file, it's purpose, and usually it's author and the date of creation.  Comments help during the reviewing and debugging process, identifying what the program is going to do and assisting the programmer in thinking clearly about the purpose of the code.

A comment should be placed at the beginning of code for each event and method.  Comments should also be placed near portions of code that require clarification or that serve an importantpurpose.

Comments display in the coding window and on source code printouts, but do not cause the program to perform a task.  They are not executed when the program runs.



Flowcharts graphically represent the logic used to develop an algorithm.  Each step in the solution is represented by a separate symbol.  Typically, flowcharts do not display programming language but instead use psuedocode, English, or mathematical notation.

Java Programming Comprehensive Concepts and Techniques - Gary B. Shelly, Thomas J. Cashman, Joy L. Starks, Michael L. Mick


This Site


Latest News