Re:Every programmer has a variable naming philosophy
by barrkel on Thursday February 04, 2010 @03:19PM
(#1101494)
I prefer not distinguishing lexically between e.g. constants and static properties / global functions (depending on the language features), etc. Many constants represent configuration choices, rather than actual mathematical or physical values that will never change.
Local variables are usually distinguished by starting with a lower-case letter, as the codebases I work with have global and method identifiers start with capitals. Global variables, to a first approximation, are never used: I have never known a case where the use of global variables wasn't regretted in the longer term. But a g_ prefix wouldn't be out of place if they must be used owing to an old codebase already littered with them.
As to "counters": for indexing for-loops, at best i through k are used - if more are needed, subroutines are used instead, so i through k can be reused. Other things that count have better semantic names than single letters.
Local variables are usually distinguished by starting with a lower-case letter, as the codebases I work with have global and method identifiers start with capitals. Global variables, to a first approximation, are never used: I have never known a case where the use of global variables wasn't regretted in the longer term. But a g_ prefix wouldn't be out of place if they must be used owing to an old codebase already littered with them.
As to "counters": for indexing for-loops, at best i through k are used - if more are needed, subroutines are used instead, so i through k can be reused. Other things that count have better semantic names than single letters.