A plea for better variable names

K

Keith Thompson

When posting sample code here, please choose decent variable names.

The worst name I've seen in common use here is "a". Since "a" is also
a common English word, it's difficult to discuss it clearly.

For small test programs, names should usually reflect either the
type of a variable or its purpose. "i" or "n" is ok for an int,
"f" for a double, "p" for a pointer. "l" for a long isn't good,
since it's too difficult to distinguish from "1".

For a very short program, "x", "y", and "z" are ok.

For longer programs, most variable names should be longer than one
character, and should reflect the variable's purpose.

But even just using "x" and "y" rather than "a" and "b" would make
life easier for those of us who are trying to help you.

Thanks.
 
A

Antoninus Twink

When posting sample code here, please choose decent variable names.

The worst name I've seen in common use here is "a". Since "a" is also
a common English word, it's difficult to discuss it clearly.

For small test programs, names should usually reflect either the
type of a variable or its purpose. "i" or "n" is ok for an int,
"f" for a double, "p" for a pointer. "l" for a long isn't good,
since it's too difficult to distinguish from "1".

For a very short program, "x", "y", and "z" are ok.

For longer programs, most variable names should be longer than one
character, and should reflect the variable's purpose.

But even just using "x" and "y" rather than "a" and "b" would make
life easier for those of us who are trying to help you.

Thanks.

Hilarious, Han! Good to see you back.

That's uncannily good.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,588
Members
45,092
Latest member
vinaykumarnevatia1

Latest Threads

Top