View Single Post
Old 11-30-2007, 02:52 AM   #1 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Images Hungarian Notation

I use Hungarian notation because you can clearly see what each variable should be containing. Albeit I do admit that with PHP being the way it is, us PHPers shouldn't have to worry about what each variable is storing, as long as it is storing something relevant to our script, right? Well, you're right, but I find it's always nice to care even though there's no call for it.

Here at TalkPHP we seem to love the Hungarian notation (Bluesaga did a little tips guide on them over here), and I have seen 1 or 2 people around the Interweb commenting on the vast amount of TalkPHP's articles about the use of sz for a string. True, sz is technically for a zero-terminated string and PHP does not have those - only C++ to name one. However, the reasoning for that is sz looks nicer than s, and for that I do admit my vanity!

I was merely wondering on other programmer's view on Hungarian notation. For me, I'd rather see:

php Code:
$szMyVariable = 'String';

Than:

php Code:
$myVariable = 'String';

I've seen people giving all sorts of pet names to their variables. In fact, the one and only Winsrev was one of those who had some very peculiar variable names if I remember rightly, but then again, didn't we all at one stage?

Another good thing about the Hungarian notation is that you can enforce variables yourself, even though PHP doesn't seem to care, by extracting the first 1 or 2 variable prefixes and then modifying its data type to match.

For further information on Hungarian notation before sharing your opinion, you may wish to have a read of its Wikipedia page.

So, are we caring too much, or is Hungarian notation really helpful in programming?
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote