Prefixes for local fields, arguments and fields
Friday, August 1. 2008
John O'Hanley wrote a Java World article about Four harmful Java idioms, and how to fix them. In this article he discusses some standard Java idioms that should be changed.
I do not want to comment on the others but on his suggestion to add different prefixes to variables:
- f for fields
- a for arguments
- no prefix for local variables
His example that should prove in his opinion that this is better readable is:
public boolean equals (Object aOther)
{
if (! (aOther instanceof Range)) return false;
Range other = (Range) aOther;
return fStart.equals(other.fStart) && fEnd.equals(other.fEnd);
}Well I couldn't disagree more with him:
Continue reading "Prefixes for local fields, arguments and fields"