The worst way to shorten names

Dropping vowels to shorten names is a terrible practice. Quick, someone give me an idea what $hdnchgdsp means, an Actual Variable from some Bad Code I'm working on today.

It's not just variables names, either. Filenames often need to be shortened, but dropping vowels is not the way to do it. You're left with unpronounceable names that are annoying to type.

The key to effective abbreviation is not removal of letters from the middle of the words, but from the end. Sometimes, it doesn't make sense to shorten a word at all, like "post". If you have a file that is supposed to "post audit transactions", call it "post-aud-trans" or "post-aud-trx", not "pst_adt_trns".

Categories:

4 Comments

chromatic said:

If you like $hdnchgdsp, you'll love Haskell.

What's wrong with just calling the file "post_audit_transactions"? Personally, I lean towards verbose variable and function names. I like my code to read like a book. A code-aware editor makes long names become just a few keystrokes. Using abbreviations that are not part of a known vocabulary just slows reading comprehension. Using good names for things is part of making maintainable software (as opposed to "throw it away and start over" software).

> What's wrong with just calling the file "post_audit_transactions"?

Nothing. Why do you ask?

The article's advice on *how* to shorten is given in the context of the *need* to shorten ("Filenames often need to be shortened"), not a preference for shortening.

Andy Lester said:

Agreed, leaving long names is often good. Mind you, I was also discussing naming of things like files, URLs, etc. Many things are named that aren't used within an editor, code-aware or not.

Leave a comment

About this Entry

This page contains a single entry by Andy Lester published on March 5, 2008 9:33 AM.

How not to do a Changes file was the previous entry in this blog.

Devel::NYTProf is the hot new profiler in town is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Other Perl Sites

Other Swell Blogs

  • geek2geek: An ongoing analysis of how geeks communicate, how we fail and how to fix it.