On May 4, 2005, at 5:38 PM, A. Kevin Baynes wrote:
I've noticed in some Java code I've read, variables starting with a single underscore or two underscores.
private static WeakHashMap __servers = new WeakHashMap();
I'm guessing that this is a coding convention from a preceding language(s) (C/C++, perhaps?), and that perhaps it is used to distiguish variable scope (globals, perhaps?)
Can someone school me on the rules?
In my experience the underscore thing is a Windows C++ convention, and is used to distinguish class member variables. It can be useful as a convention if your IDE can't automatically tell the scope of a variable. Never seen a double underscore though.
I have - I've seen double underscores used to indicate a member variable that is intended to be accessed solely through a getter/setter. The idea being, if you see the variable used 'nakedly' outside of its getter/setter, the author has forgotten that intent and the code may be incorrect.
I use both conventions (the double underscore rarely), and I just want to say that I have never been a Windows C++ programmer ...
___________________________________________________________________ F is for Fire that burns down the whole town! U is for Uranium ... BOMBS!! N is for No Survivors!!
_______________________________________________ Juglist mailing list [email protected] http://trijug.org/mailman/listinfo/juglist_trijug.org
_______________________________________________ Juglist mailing list [email protected] http://trijug.org/mailman/listinfo/juglist_trijug.org
