On 03/08/2011 20:02, Jim Gibson wrote:
On 8/3/11 Wed Aug 3, 2011 9:41 AM, "Tim Lewis"<twle...@sc.rr.com>
scribbled:
First Microsoft decides that Hungarian Notation is no longer a standard in VB;
I am still going through withdrawal from that. Now camel Case is gone? I
will adapt my programming to use the underscores.
CamelCase is not gone. Perl will allow you to use any case characters and
underscores in variable names. Shlomi prefers to use lower-case letters and
underscores, and he tells everybody to do likewise. However, you are free to
use whichever style you wish.
People should be careful not to confuse personal preferences with good
programming practices. While there is a benefit to using a consistent style,
the exact style used should be chosen by the people involved, not outsiders.
My advice is to listen to the experienced programmers, then do what you
think is best. Do not adhere to some advice without knowing the reason --
and agreeing with that reason.
Ask the person giving the advice: what is the advantage of underscores over
mixed-case variable names? If it is "readability", why is one style more
readable than the other. Maybe it is just what you are used to.
I agree that everybody is free to use the style that they prefer, but
unless they are certain that no one else will ever read their software
it is very useful if a program follows a popular standard. Especially on
a beginners' list, where the express purpose is to show people your code
and ask for advice, it is a very good thing if the layout and coding
standards are as transparent as possible.
perldoc perlstyle
is a reasonable authority, and on this matter it says
* While short identifiers like $gotit are probably ok, use underscores
to separate words in longer identifiers. It is generally easier to
read $var_names_like_this than $VarNamesLikeThis, especially for
non-native speakers of English. It's also a simple rule that works
consistently with "VAR_NAMES_LIKE_THIS".
Package names are sometimes an exception to this rule. Perl
informally reserves lowercase module names for "pragma" modules like
"integer" and "strict". Other modules should begin with a capital
letter and use mixed case, but probably without underscores due to
limitations in primitive file systems' representations of module
names as files that must fit into a few sparse bytes.
However it also says
Each programmer will, of course, have his or her own preferences in
regards to formatting, but there are some general guidelines that will
make your programs easier to read, understand, and maintain.
Cheers,
Rob
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/