The following general guidelines apply to choosing identifier names in your programs:
middleInitialrather than the shorter versions
setTheLengthFieldshould be shortened to
Productsin the same program for fear of mixing them up.
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
incomeTax are preferable to
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