My Secret Life as a Spaghetti Coder
home | about | contact | privacy statement
It's been said and repeated and retweeted:
Code is read much more often than it is written, so plan accordingly
I think that's sound advice. But is there ever a time when you ought to use cryptic one-letter variable names and strange symbols in your code?

If we're admonished to write code so that it's easier to be read, then I think, yes, depending on your intended audience, there are times when it's OK.

For example, if you work in a science lab and are implementing a math theorem, everyone on the team knows how to read and probably prefers the concise notation. Would that not be a good time to break the no-single-letter-variable-name rule?


Hey! Why don't you make your life easier and subscribe to the full post or short blurb RSS feed? I'm so confident you'll love my smelly pasta plate wisdom that I'm offering a no-strings-attached, lifetime money back guarantee!

Leave a comment

It could be argued that to truly reach maximum efficiency, that no single bit of memory be used unnecessarily. In this modern age, memory and disk space are not the immediate and serious constraints that they once were. But there might be an argument that in some super compact environment, bumming the code down to the smallest implementation makes it run faster. Consider jQuery. They produce a "minified" version of their code to use in the production environment (no unecessary whitespace,etc.,) but the "human readable" one is several kilobytes larger just to help make it readable by the developer.

Posted by David on Aug 29, 2012 at 03:35 PM UTC - 5 hrs

Thanks for the comment David!

I could see that, but in those cases, we can keep the original source code readable by humans and use an intermediate step (like the minification process, or some compilation) that would take care of it for us.

Is there a case you're thinking of where we'd need to write it that way with the intention of being read by anyone other than a computer?

Posted by Sammy Larbi on Aug 29, 2012 at 05:26 PM UTC - 5 hrs

I like my names to be inversely proportional to their scope. Short-lived variables can have really short names, but those that stick around a while get nice, long descriptive ones.

Posted by Clay Smith on Sep 10, 2012 at 01:11 PM UTC - 5 hrs

That's a good point Clay - `i` may be a horrible name for a variable in a longer method, but in a tight loop it's probably ok.

Posted by Sammy Larbi on Sep 17, 2012 at 01:54 PM UTC - 5 hrs

Thanks for the Info!

Posted by Steven M on Jan 22, 2013 at 02:20 AM UTC - 5 hrs

Leave a comment

Leave this field empty
Your Name
Email (not displayed, more info?)


Subcribe to this comment thread
Remember my details

Picture of me

.NET (19)
AI/Machine Learning (14)
Answers To 100 Interview Questions (10)
Bioinformatics (2)
Business (1)
C and Cplusplus (6)
cfrails (22)
ColdFusion (78)
Customer Relations (15)
Databases (3)
DRY (18)
DSLs (11)
Future Tech (5)
Games (5)
Groovy/Grails (8)
Hardware (1)
IDEs (9)
Java (38)
JavaScript (4)
Linux (2)
Lisp (1)
Mac OS (4)
Management (15)
MediaServerX (1)
Miscellany (76)
OOAD (37)
Productivity (11)
Programming (168)
Programming Quotables (9)
Rails (31)
Ruby (67)
Save Your Job (58)
scriptaGulous (4)
Software Development Process (23)
TDD (41)
TDDing xorblog (6)
Tools (5)
Web Development (8)
Windows (1)
With (1)
YAGNI (10)

Agile Manifesto & Principles
Principles Of OOD
Ruby on Rails

RSS 2.0: Full Post | Short Blurb
Subscribe by email:

Delivered by FeedBurner