[nycphp-talk] Length of variable names
Andy Dirnberger
dirn at dirnonline.com
Tue Jul 3 12:41:19 EDT 2007
I had a professor back in college who told a story about a program he
received from a student in which each variable was the name of a beer. The
student had done such a good job documenting it, though, that the purpose of
each variable was easily understood.
To get back on topic, Hungarian Notation is one way of prefixing variables
(does anyone still use it though?).
http://web.umr.edu/~cpp/common/hungarian.html
The important thing to keep in mind is to be consistent in your conventions.
It will make things easier for someone (even you) reading your code.
As far as i goes, I've always assumed it was just shorthand for something
like index or increment. Nested for loops are often then controlled with j
and then k. You can use these with confidence that people will understand
the meaning. But if you feel more comfortable using a variable called
$counter than one called $i, by all means do so. There are plenty of people
out there who refuse to use i.
> -----Original Message-----
> From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org]
On
> Behalf Of David Krings
> Sent: Tuesday, July 03, 2007 9:50 AM
> To: NYPHP Talk
> Subject: [nycphp-talk] Length of variable names
>
> Hi!
>
> Is there any (noticeable) difference between using short variable names
> and long ones? I rather use variable names such as $firstnamecounter
> than just $i, $john, or $doe (I've seen code where the developer used
> almost exclusively his first and last name for just about everything).
> I try to give each important variable a name that is descriptive and
> unique within my project so that I can name the same thing by the same
> name across multiple scripts.
>
> I just wonder if I should get used to a different naming convention now
> that my projects get more complex.
>
> David
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
More information about the talk
mailing list