Fog Creek Software
Discussion Board

Why leave vowels out of variable names?

This all began with FORTRAN, which originally allowed (I believe) six character variable names.

Wake up. It is no longer 1957.

Also annoying is the lack of uniformity.

As in, one place printer is changed to "printr", someplace else to "prnter", and (I actually saw this once) to "ptr".

The problem is that one tends to remember variables as PrinterControlBlock, and when it's time to type the name, you have to fumble around to remember, is it PrntrCtrlBlk or PrintrCtlBlck or maybe PtrControlbk.

Just my Sunday morning rant.

Sunday, June 13, 2004

With a modern-day IDE, there's no excuse to use smaller cryptic names for variables, functions, classes, etc.

Green Pajamas
Sunday, June 13, 2004

Thts hrrbl.

son of parnas
Sunday, June 13, 2004

What the hell are you talking about?

Programmers haven't abbreviated words in software for decades.

Sunday, June 13, 2004

>What the hell are you talking about?

>Programmers haven't abbreviated words in
>software for decades.

Sorry to contradict, but at my current job, it is done all over the place.

I am frustrated because I see this continuing to happen, even in brand new code.

Fortunately, Java books tend to discourage this kind of naming practices.

Sunday, June 13, 2004

Actually they're not abbreviating variables; they;re texting their  friends but sometimes the boss comes along and they have to pretend it's part of the code.

Stephen Jones
Sunday, June 13, 2004

<insert (HungarianNotation == bad) rant here>

Greg Hurlman
Sunday, June 13, 2004

To some extent you're right, it's a tradition.

But long variable names aren't necessarily all good either; I can't read code where even a simple assignment takes two or three lines and function calls go on for a quarter of the screen. A general rule of thumb I follow: the more frequently a variable is used in a block of code, the shorter the identifier should be.

Tom H
Sunday, June 13, 2004

I agree the pracitce of abbreviation is confusing.  However, there are still some identifier length limits such as column names in databases. 

One solution is to adopt standard abbreviations but such rules are seldom followed 100%

Sunday, June 13, 2004

Well, where I work, it would be "PRTR_CTRL_BLCK" which is even more stupid...

Sunday, June 13, 2004

"Cd wrttn wtht vwls s mch trsr

: When using abbreviations inside variable or method names, break the boredom with several variants for the same word, and even spell it out longhand once in while. This helps defeat those lazy bums who use text search to understand only some aspect of your program.

Consider variant spellings as a variant on the ploy, e.g. mixing International colour, with American color and dude-speak kulerz. If you spell out names in full, there is only one possible way to spell each name. These are too easy for the maintenance programmer to remember.

Because there are so many different ways to abbreviate a word, with abbreviations, you can have several different variables that all have the same apparent purpose. As an added bonus, the maintenance programmer might not even notice they are separate variables."

How To Write Unmaintainable Code - Naming

Sunday, June 13, 2004

The font you use can be important re: variable name length too - I like ProFont, since it's perfectly readable at 8 point on my 1024x768 resolution monitor. And at 8 point you see a helluva lot more on a line, and on the screen, than you do at 12 point.

Christo Fogelberg
Sunday, June 13, 2004

Stop complaining.  If they managed to write most of the Bible without vowels, surely you can manage a bit of code. :)

Ged Byrne
Monday, June 14, 2004


I think I'm implementing your company's library.  That naming scheme is crazy talk.

Monday, June 14, 2004

A fellow programmer abbreviates "counter" to "cnt" which, when you try to sound it out, happens to be a derogatory term for a part of the female anatomy (and for women in general). It's annoying, but I can't point it out without revealing the nature of my own dirty mind.

Nearly Nameless
Monday, June 14, 2004

"..the Bible without vowels..." -- AHA!

THAT explains why the Bible can be so vague, so full of double meanings, at the same time prescriptive, yet vague on what he prescription exactly is.

I don't think we want to emulate this in our software.  Ambiguity is the devil's playground...

Monday, June 14, 2004

The truth is, there is more information content in the consonants -- there are just more of them than vowel sounds, most of which are inferred to large degree by the vowels around them.

That question aside, I think abbreviating is a good thing compared to names like CallThisFunctionToPerformATask() which is both verbose and unhelpful.

Jeff Kotula
Monday, June 14, 2004

ptr is pretty common shorthand for pointer, I've seen in most books I've ever read that had example code using pointers.

Zach M
Monday, June 14, 2004

I agree: CllThsFnctnTPrfomTsk() is so much more readable.

Just me (Sir to you)
Tuesday, June 15, 2004

Agreed.  'PerformTask()' is probably as much as you need.  The Verb-Object english sentence form has been recommended for quite some time.

In 'C', I also use the Object-Verb form (which C++ requires you use, of course).  If you see your functions in alphabetical order, this sorts them together.

For example: Verb-Object:

Push_Stack(StackPtr * Stack, void * Node);
void * Pop_Stack(StackPtr * Stack);
int IsEmptyStack(StackPtr * Stack);

and Object-Verb:
Stack_Push(StackPtr * Stack, void * Node);
void * Stack_Pop(StackPtr * Stack);
int StackIsEmpty(StackPtr * Stack);

And the C++ form:
MyStack->Push(void * Node);
MyNode = MyStack->Pop();
EmptyVal = MyStack->IsEmpty();

Tuesday, June 15, 2004

Two years ago I was told by the chief architect at my client's company to go back over existing code and follow the TLA methodology.  When I asked what methodology that was, I was told it is the Three-Letter-Acronymn methology.  (I'm serious)  I mentioned that I had never heard of a methodology based on TLAs, and asked exactly how I'd implement it.  The chief architect said, and I'm really not kidding, that all filenames must be no longer then 3 letters plus a 3 letter extension.  All class names must be capped and no more then 3 letters.  Functions and method names must also be no more then 3 letters.  All variables also must follow same with a mix of hungarian prefixes allowed.

I've been writting code for about 18 years professionally.  It was the most absurd thing I'd ever heard.  And he was saying it with a straight face and adament that I go back through the code I had produced in the last 4 weeks (about 50,000 lines debugged/tested) and make the changes.  It was all OO C++ (no hungarian) with names like VideoDisplayPanel (he wanted that changed to VDP).

That contract only lasted another 3 weeks as I was 'being difficult' ...

Saturday, June 19, 2004

*  Recent Topics

*  Fog Creek Home