NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP Coding Standards

Jeff Knight jeff.knight at gmail.com
Fri Dec 9 14:42:36 EST 2005


If it doesn't follow a well recorded, defined list of types, it isn't
"Hungarian".  On one hand, I've often found it useful to distinguish
between parameters ($p_) and local vairables ($l_) in my functions and
methods, on the other hand, it kind of defeats the purpose of
auto-complete, since all your variable names begin with a small set of
notations. On some occasions I've even found it useful to go so far as
to add notation for keys ($k_) and values ($v_) in my longer loops,
but that is definitelly not "Hungarian". I can't really ever recall a
time where the type hinting character ever helped me out, but maybe
someday... That being said, type and scope hinting in a name can be
useful, and as far as I'm concerned are as much an indication of what
a thing is as some arbitrary label, in fact, it can often make your
names shorter and more to the point. For example compare taking an
input array of $p_aNames, looping through them as $v_sName and
building some local array for return in $l_aNames against using
longer, studlyier names for the "Name" to differentiate them, such as
$NamesInput, $NameFromLoop, $NamesOutput. Typically, on a project, I
wait until it is late and I've had a few beers to start naming things
anyway, so anyone following my example is probably in deep trouble.

On 12/9/05, csnyder <chsnyder at gmail.com> wrote:
> On 12/9/05, Morgan Craft <morgan at forsalebyowner.com> wrote:
> > What about Hungarian notation?  I had not heard of it till I recently
> > started my new job.  I find the naming convention useful, especially
> > when all our database fields have the corresponding notations.  I'm sure
> > this coding standard could be used for other languages that do not
> > require data types to be declared.  But is this something that should be
> > included within the PHP coding standard?
> >
> > Hungarian Notation(wiki): http://en.wikipedia.org/wiki/Hungarian_notation
> >
>
> Gack! Not in my code, thanks. Names are names, not type declarations.
>
> But if you like it, more power to ya. I hope you're consistent, and
> have a well-defined list of types in your coding standard so that
> whatever poor bloke has to change the code in 5 years can figure out
> what all the notations mean.
> _______________________________________________
> New York PHP Talk Mailing List
> AMP Technology
> Supporting Apache, MySQL and PHP
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.nyphp.org
>



More information about the talk mailing list