Re: Suffix _T for types found good



"Jeffrey R. Carter" <spam.jrcarter.not@xxxxxxxxxxxx> wrote in message
news:Y9Imk.287972$yE1.85979@xxxxxxxxxxxx
amado.alves@xxxxxxxxx wrote:
IIRC the rationale for "index : anIndex" is that it sounds like
English "index is an Index". Natural language syntax is a bitch!

"Index is an index" is at best a tautology and at worst meaningless; in
other words, this approach adds no value. Yet another mindless rule to
avoid the effort of thinking up good names.

"Index" is a poor variable name. What is it the index of?

First_Comma : Index_Value;
Start_Position : Index_Value;

and so on. Good names add information.

Funny, with my simple example of anIndex you comment that anIndex is
meaningless and go on to use Index_Value as being more informative. Your
example is to simple and worthless as well. All variables contain values.

Perhaps a better example is more like:

lengthIndex : aLengthTableIndex;

is more useful.

And yes the way I read it is in the natural language way:

lengthIndex is a length length table index.

I've seen code that uses the a prefix on variable names. After getting used
to the opposite convention it makes it hard to read.

Personally I prefer the _Type and _Acc_Type suffixes.

One other thing to note: Once I got used to reading and writing code using
these conventions, I found:
1) It makes reading code that follows these conventions a lot easier
2) It makes reading code that does not follow these conventions harder
(you get used not having to infer based on context).

Regards,
Steve


--
Jeff Carter
"To Err is human, to really screw up, you need C++!"
Stéphane Richard
63


.



Relevant Pages

  • Re: question about struct??
    ... How does the name "cobject" tell you that it's a pointer type? ... Reading code isn't reading English. ... So even if I use conventions that make it ... have an easier time grasping the code. ...
    (comp.lang.c)
  • Re: Suffix _T for types found good
    ... It makes reading code that follows these conventions a lot easier ... It makes reading code that does not follow these conventions harder ... If you review a lot of other people's code, you tend to learn how to look past ... The Rhythm has control. ...
    (comp.lang.ada)