« Now This Would Make Me Mad | Main | On "Blogging for Dollars" »
Wednesday
Jan192005

Fun With Hungarian Notation

Even though ColdFusion is "loosely typed," I've been a believer in Hungarian notation for a couple of years. It's a handy way to keep track of what data type a variable holds, and it prevents collisions with reserved words. Besides, it seems that ColdFusion's typing is getting a little less loose all the time. Here's the convention that we've settled on:

Data TypePrefixExample
Array ary aryCart
Boolean b bIsAuthenticated
Date dt dtCreated
Decimal d dTotal
Integer i iCount
Object obj objEmployee
Query q qArticles
String s sEmail
Structure stc stcGlobal

 

Of course, depending on your variable name, using Hungarian notation can lead to variable names like:

  • bOneTime - A Boolean indicator of whether something is a one-time event, but I'm sorry. Bone time. Killed me.
  • sException - A string exception. Sexceptional.

Hungarian notation. Both functional and occasionally mildly humorous.

Reader Comments (2)

Dude, you said "bone time".
hehe.
Have there been any revisions, second thoughts or controversies about using Hungarian notation?

October 31, 2006 | Unregistered CommenterPhillip Senn

Phillip - With ten developers on our team, there are controversies when we decide to do anything. We recently considered getting away from the Hungarian notation, because as we continue to look at code-generation tools and frameworks (particularly ORMs), some of them would create field labels based on the column name in the database, and sLname isn't quite as user-friendly.
Also, looking into lazy loading, we were creating objects that initialized to empty strings, and it didn't seem right to have objEmployee = "" (not an object).
At the end of the day, we stuck with the Hungarian simply because we were all used to it. No regrets.
Of course, things can always change.

October 31, 2006 | Unregistered CommenterCharlie

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>