Ugh! Your shorthand is too short!

Started by
42 comments, last by l0calh05t 10 years, 2 months ago

Usually it's people who come from math backgrounds. They are very used to, and comfortable with using single letter symbols to represent everything. I would always notice it back when I was in school, and the math teachers would have some programming project, either a framework for us to use or a sample or whatever. It was always single letter stuff. While frameworks and samples from programming or game projects teachers, they would use descriptive variable names.

Advertisement

The more annoying thing aboug one-letter variables is about highlighting or finding them (pray you do not have to refactor such code), not so much about understanding what they mean (if the programmer is only somewhat sensible, the purpose of one-letter names is usually still obvious).

But once you find out that your editor lets you conveniently highlight all occurrences of greater-than-N substrings (usually N=3) you start shouting at people who use one-letter variables because it doesn't work with the default settings, nor is there a way you could configure it so it works in a usable way without highlighting every frequently occurring letter in every keyword too.

Well, that's only an argument for getting a better editor. If your editor does not find or highlight single-character variable names out of the box it's already broken.

Stephen M. Webb
Professional Free Software Developer

I was trying to learn about b-trees, and so I looked around and found this implementation, full of one letter variable names:

http://attractivechaos.awardspace.com/kbtree.h.html

then one thinks for a moment "hey, this is where C could use a more powerful preprocessor"...

then thinks for a moment more "I already wrote one before, it didn't help all that much, was inconvinient to use, and generally ended up not really used much...".

but, yes, sadly I have done this sort of thing before, just not usually this much at once, in a few cases (typically for statically-typed interpreter logic and similar, where basically otherwise similar logic has to be repeated endlessly for N-way combinations of types).

Use longer names instead of single letter variables. Consider replacing

a with alpha

b with beta

d with delta

etc.

I do hope you are being sarcastic


I do hope you are being sarcastic

Nope. I do the same with indexes:

i with idx

j with jdx

k with kdx


I do hope you are being sarcastic

Nope. I do the same with indexes:

i with idx

j with jdx

k with kdx

Indices.

And it's not very object oriented is it?

Consider replacing with

int GetIndex(int idx) { return idx; }

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

Indices.


Okay. sad.png



And it's not very object oriented is it?
Consider replacing with

int GetIndex(int idx) { return idx; }


Ah yes, that's from a factory created from the DecimalSystem.GetArrayAccessorByIndexFactoryCreator(), isn't it?

I like the way you code reviewed your edits ;)

I am being sarcastic in case noone noticed.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

I was trying to learn about b-trees, and so I looked around and found this implementation, full of one letter variable names:

http://attractivechaos.awardspace.com/kbtree.h.html

THE HORROR.

To the eye of someone who has done years of maintenance programming,and looked at microsofts various SDK samples (and looked at peoples code on this site's forums), that is trivial.

There is the opposite problem of long variable names smearing code statement across multiple lines

--------------------------------------------[size="1"]Ratings are Opinion, not Fact


Indices.

Indexes, indices, who cares? Both plural forms are valid.

This topic is closed to new replies.

Advertisement