>Hungarian notation

>Hungarian notation was, and is, a good idea.
Unfortunately prefixing the variable with the type has today become suffixing:
sCustomerNumber -> customerNumber
sPassword -> passwordString
nMax -> maxValue

What is the reason for this? Is it harder to read nCustomer than customerNumber? I don’t think so. Instead more space/characters are used for communicating the same information.

Think of the ever present”customer number”. Written as customerNumber at first look it looks like a number, a series of figures. Now we know that a customer number has dashes and letters in them so it is really a string, like customerNumberString. Written with hungarian notation it is sCustomerNumber and clearly a string.

Now I have come to use non camelCasing like everyone else but only for strongly typed languages like C# which can by itself differ between strings and integers. For loosely typed languages like Javascript or PHP i still use hungarian notation.

My rules for hungarian notation in Javascript is like:
sXXX for strings
nXXS for integers (bytes, long integers, whatever)
fXXX for floats (doubles, decimal, whatever)
oXXX for many objects (oUser, oBoat, whatever)
myclassXXX for other object (userProtagonist, accountMain, accMain, whatever)
rsXXX for record sets
bXXX for booleans
anXXX for arrays of integers
asXXX for arrays of strings
cXXX for constants and characters – I am not totally happy with this

There has been no reason to make it more complex than that.

Leave a Reply