Variable naming convention
I just read Tor Norbye's latest blog entry Code Advice \#11: Initialize fields using the property name, and I have to say I disagree with him. I used the coding style where the name of the variable is prefixed with a character to indicate the scope. The following table outlines the rules.
|static final||All uppercase||MAX\_TEMP|
So to use Tor's example, the setter method would be written as:
Advantages of this style are:
- Misalignments stand out, as in:
- You can still use nice English names for parameters and local variables.
- It is easier when reading code fragments (for example diffs) to determine the scope of a variable. For example, it is easy to read the following code fragment:
- It is readily supported by IDE's that generate setters and getters.
I enforce this style with the following checks in my Checkstyle configurations: