Java Programming Style Guide

Naming Conventions

The following general guidelines apply to choosing identifier names in your programs:

Rationale:

You should write your code with the aim of making it understandable to others. Others will need to read and understand your code and one of the major keys to understanding is through the use of meaningful identifier names.

By using meaningful names, you go a long ways towards writing self-documenting code. That is, code that is understandable on its own without requiring accompanying comments. For example, look at the following code segment and determine for yourself that the variable names salesTax and incomeTax are preferable to tax1 and tax2 because the names are self documenting.

double tax1;       // sales tax rate (example of poor variable name)
double tax2;       // income tax rate (example of poor variable name)

double salesTaxRate;      //no comments required due to
double incomeTaxRate;     //self-documenting variable names