hungarian notation

All things techie, be they discussions on troubleshooting, video encoding, programming, or algorithm design.

Moderator: Nuxius

hungarian notation

Postby TerraFrost » Sat Apr 19, 2008 7:08 pm

Whenever you look at sample VBScript on Microsoft's website, you see it. Variables have names like $sAddress or $strAddress or maybe even $usAddress or whatever. This is often called Hungarian Notation.

Often times, the prefix represents the type. eg. s for a string, i for an integer, etc. Which is kinda redundant, as discussed here:

Eventually, programmers who never understood Hungarian in the first place noticed that the misunderstood subset they were using was Pretty Dang Annoying and Well-Nigh Useless, and they revolted against it.

Now, the article I just quoted suggests that there are two different types of Hungarian Notation one can use. Apps Hungarian or Systems Hungarian. The kind I described earlier is systems hungarian.

Apps hungarian, per the article, is where you don't preface the variable name with the name but rather something, in theory, more meaningful. eg. instead of just saying $sAddress, because it's a string, say $sAddress or $usAddress, depending on whether or not the string has (for example) had the html entities properly encoded against to protect against XSS. In this case, s means "safe" and us means "unsafe".

The problem with Apps hungarian is that it's a PITA if you don't know what all the possible prefixes are, and someone whose just diving into the code for the first time isn't going to have a clue what those mean. In fact, for them, it'll probably cause more confusion than anything else because you simply have that much more to remember.

For example, which is easier to remember? "gghreersdgszxcgs" or "The remote control doesn't work"? You have less characters to memorize in the first case but in the second case, you're not memorizing characters - you're memorizing entire words. Meaningless prefixes (atleast from the perspective of a new programmer) are only going to confuse you. They make the variable names unnecessarily complex and in general, make them harder to remember (because not only do you just have to remember the variable name - you have to remember the meaningless prefix, too).

So, all in all, I think hungarian notation sucks and the world would be better off if it just died.
Legendary Guard
Posts: 12357
Joined: Wed Dec 04, 2002 6:37 am

Re: hungarian notation

Postby Drazo » Sat Apr 19, 2008 10:49 pm

I don't do VBScript....but I don't use prefixes to mark what data type the varibles are....I just use meaningful words or (most usually) meaningful acronyms....which I soon forget what it exactly is so I review the code to remind myself anyway. :lila

I hardly ever use any comments in my coding either.... <.<
[Don't watch here carefully]
User avatar
Heroic Guard
Posts: 3935
Joined: Mon Jan 06, 2003 8:59 pm

Return to Communications Center

Who is online

Users browsing this forum: No registered users and 2 guests