Re: Symbol Name Length (Was: STL Memory leak?)
Daniel Pitts wrote:
James Kanze wrote:
[..]
And of course, I notice that you've adopted a convention for
abbreviating names as well: why not sourceString and
destinationString? (Objects should be qualified nouns, and
abbreviations aren't used, according to the usual naming rules.)
Why should they be qualified? Are your referred to as PersonJames or
JamesPerson? or, pJames to adopt some M$ notation...
My point with that is you should choose the simplest name that conveys
enough information.
.... *given any particular context* (and I believe it's important). For
example, our development group has several people named James. In a
conversation we usually have to qualify which James we're talking about.
AFA 'strcmp' is concerned, it's probably not complex enough a context
to qualify 'source' and 'destination' with an additional type indicator...
> The difficulty, as always, is that both "simplest"
and "enough information" are subjective terms. Hopefully the "average"
person will have an "average" interpretation of
simplest-with-enough-information.
That's what the coding style documents are for. It is not inconceivable
to create a set of rules for variable naming. Once it's done, the
subjective element is out of the equation. Of course, the document has
to allow for growth, evolution, and not only in the tools' capabilities,
but in the team's members' skills to read and interpret code. I've seen
coding style docs with the requirement that a variable should always
have at least two letters in its name. I can't write
for (int i = 0; i < somecount; ++i)
and instead have to use 'ii':
for (int ii = 0; ii < somecount; ++ii)
Nobody remembered why it was established. So, common sense and periodic
reviews of the policies are important, too.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask