Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Commonly accepted style guide?

by Tanktalus (Canon)
on Sep 25, 2005 at 05:20 UTC ( #494868=note: print w/ replies, xml ) Need Help??


in reply to Commonly accepted style guide?

Style being de-facto standards: yes, wholeheartedly. As for "community standards", I'll leave that as a philosophical question on what "community" is ;-)

Items to pay attention to:

  • Use of & in function calls.
  • Any failure to use strict and warnings, or any use of no strict without a comment explaining why this is necessary.
  • A for/foreach loop whose sole job is to push values (whether they're the loop variable or converted from it) onto an array - cf. @array = map {...} @list;
  • Using backticks in void context. Or any other construct that returns a list, e.g., map.

More comfortable: Using lots of modules. It means that the author understands his/her tools, and is using stable modules to do work rather than reinventing bugs in new wheels.

Experience level: If you are willing to agree that experience level and amount of experience are not tightly bound, sure. I know a number of people who have been writing perl for longer than I've been in the field who I'd say are extremely low-leveled. They just never progressed past perl4-style programming. So, to a point, yes - bad style shows a lack of time writing and maintaining code - many good styles should be obvious once you have to maintain code. Anyone with a modicum of experience should have learned good style, whether exposed to it from others or not. From the other direction, I do think it's completely possible for someone with no experience in writing code to quickly be high-level programmers if they are good at learning and applying what others before them have encountered. I think the bottom line to the question is relating to how comfortable you feel in maintaining someone else's code - and that really does come down to style. Mostly.

Yes, my style has changed. I'm not sure it's always an improvement ;-). How it has changed? As I learn more about perl idioms, I tend to use them. They make my programs more robust as these are general-purpose ideas that have been around for a long time, well-tested, and probably even have optimisations put into the perl interpreter to help speed them up.

Your final question: I think style and maintainability are nearly interchangeable terms. They are tightly intertwined. And, in my personal arrogance ;-), I think that's why I'm an advanced programmer.


Comment on Re: Commonly accepted style guide?
Re^2: Commonly accepted style guide?
by Anonymous Monk on Sep 26, 2005 at 09:16 UTC
    Any failure to use strict and warnings, or any use of no strict without a comment explaining why this is necessary.

    Using 'no strict' without a comment is something you pay attention to, and I presume you flag it negatively? I disagree. I consider commenting the obvious as a sign of an immature or insecure coder. Commenting the obvious includes the classical:

    i++; /* Increment i */
    but doesn't stop with:
    { no strict 'refs'; *{$caller} = &{$something}; }
    or
    my @list = do {no warnings; qw /foo #bar baz,/};

    Using backticks in void context. Or any other construct that returns a list, e.g., map

    Nothing returns a list in void context. Lists are only returned in list context. And programmers who think that 'map' in void context creates a list internally are showing signs of not keeping up with modern Perl development. ;-).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://494868]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (14)
As of 2014-07-31 17:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (249 votes), past polls