TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
View Poll Results: Is Hungarian Notification useful?
Indeed 8 72.73%
Not really 2 18.18%
I don't give a monkeys 1 9.09%
Voters: 11. You may not vote on this poll

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 11-30-2007, 02:52 AM   #1 (permalink)
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
Old 11-30-2007, 03:30 AM   #2 (permalink)
The Acquainted
 
Join Date: Oct 2007
Posts: 170
Thanks: 18
maZtah is an unknown quantity at this point
Default

I'm using it since I saw you guys using it here. In my opinion it is very useful! Hence I'll never turn back to another prefixes blabla (sorry for my English, it's late and I've drunk some beer;))

Previously I used n for number, and s for string. So;

PHP Code:
$nId 1;
$sKeyword 'TalkPHP'
But the Hungarian Notation is much better!
maZtah is offline  
Reply With Quote
Old 11-30-2007, 10:28 AM   #3 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

i like it, but its another subject that sets some programmers off on a religious war with one another, the same with brace positioning.
Those kinds of programmers (most of my old uni lecturers, i might add) would throw a wobbler if one line was incorrectly indented, they annoy me, whilst the point of indentation and notation helps readability is valid, i think you can take it a little too far.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 11-30-2007, 12:14 PM   #4 (permalink)
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
Default

You may just have a point there. Although I very rarely reduce myself to arguing about programming as it's not something I feel compelled to argue about. Light debating is fine as it finds the best way to do things. But arguing? No, no, programming isn't anything to get worked up about. Then again what is? I'm very chilled. *Ahhhh*.
__________________
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
Old 11-30-2007, 02:18 PM   #5 (permalink)
The Reckoner
Advanced Programmer Top Contributor 
 
Karl's Avatar
 
Join Date: Sep 2007
Posts: 437
Thanks: 22
Karl is on a distinguished road
Default

Yep you have a very good point there sketch. I'm personally a little obsessive about notation and indentation, but I don't generally bitch about it or have a go at people. I just can't help myself from tidying the code up - indenting everything so it's all nice and pretty. Only after I've finished prettying up the code do I begin working on it. You can probably imagine my disgust when having to work with vBulletin, as I have over the last week.

With that said though, it isn't the type of indentation that bothers me, it's the complete lack of indentation that really infuriates me.
__________________
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
Karl is offline  
Reply With Quote
Old 11-30-2007, 03:10 PM   #6 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

I too organize code before i'll even consider doing anything with it, its not that i think the guy is a baboon or anything because he places his brace after the function name instead of a new line, its just im not used to it.
Quote:
With that said though, it isn't the type of indentation that bothers me, it's the complete lack of indentation that really infuriates me.
yea the complete lack of annoys me its just laziness and ends up blinding me coz i cant tell top from bottom.
But it is a sad fact that there are programming purists out there who throw tantrums if you present code to them in a different style to their own.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 11-30-2007, 03:18 PM   #7 (permalink)
The Reckoner
Advanced Programmer Top Contributor 
 
Karl's Avatar
 
Join Date: Sep 2007
Posts: 437
Thanks: 22
Karl is on a distinguished road
Default

Quote:
Originally Posted by sketchMedia View Post
But it is a sad fact that there are programming purists out there who throw tantrums if you present code to them in a different style to their own.
Lol, yes it is. Very sad indeed.
__________________
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
Karl is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 05:13 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design