Java Reference
In-Depth Information
A group of constants that represent alternative values of a set, or, less frequently,
masking bits in an integer value, are sometimes usefully specified with a common ac-
ronym as a name prefix.
For example:
interface ProcessStates {
int PS_RUNNING = 0;
int PS_SUSPENDED = 1;
}
Local Variable and Parameter Names
Local variable and parameter names should be short, yet meaningful. They are often
short sequences of lowercase letters that are not words, such as:
• Acronyms, that is the first letter of a series of words, as in cp for a variable
holding a reference to a ColoredPoint
• Abbreviations, as in buf holding a pointer to a buffer of some kind
• Mnemonic terms, organized in some way to aid memory and understanding,
typically by using a set of local variables with conventional names patterned
after the names of parameters to widely used classes. For example:
in and out , whenever some kind of input and output are involved, patterned
after the fields of System
off and len , whenever an offset and length are involved, patterned after the
parameters to the read and write methods of the interfaces DataInput and
DataOutput of java.io
One-character local variable or parameter names should be avoided, except for tem-
porary and looping variables, or where a variable holds an undistinguished value of a
type. Conventional one-character names are:
b for a byte
c for a char
d for a double
e for an Exception
f for a float
i , j , and k for int s
l for a long
o for an Object
Search WWH ::




Custom Search