Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re (tilly) 3: Efficiency in maintenance coding...

by tilly (Archbishop)
on Nov 15, 2001 at 04:25 UTC ( [id://125471]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Efficiency in maintenance coding...
in thread Efficiency in maintenance coding...

Maintainable by whom?

Maintainability is an interaction between code, users, and programmers. I think that most "Perl hackers" would prefer to work with eduardo's code. Most people who put Perl on their resumes would prefer what dws produced.

I personally prefer working with people who can figure out things like:

$freq_count{$_}++ for get_words(<>); # Takes one or more strings, returns all words it finds. sub get_words { map /(\w+(?:'[ts])?)/g, @_; }
(Not that I try to abuse people, but should I find something convenient, I like not having to worry about whether the next person can figure that out.)

Replies are listed 'Best First'.
Re: Re (tilly) 3: Efficiency in maintenance coding...
by perrin (Chancellor) on Nov 15, 2001 at 19:56 UTC
    This is difficult subject to discuss without histrionics. I mentioned on the CB one day that I try to avoid the use of $_ because I think it makes code harder to read, and it was not a very popular notion.

    Most of the advanced people on this site would certainly prefer eduardo's version, but my experience has been that many of the people I have to work with every day just don't know Perl well enough to quickly grok stuff like $frequency{$_}++ for (split /\W/, <>) quickly. Because of this, I try to stick to the more standard control structures when I can, and especially avoid stacking up a lot of operations on one line.

    I still use things like map, grep, hash slices, and extended regular expressions, but not when something simpler will work with similar efficiency.

      I try to avoid the use of $_ because I think it makes code harder to read ...

      Well, i suppose you are likewise going to start removing 'it' from your vocabulary. ;)

      But i agree that $_ can be abused.

      jeffa

      L-LL-L--L-LL-L--L-LL-L--
      -R--R-RR-R--R-RR-R--R-RR
      F--F--F--F--F--F--F--F--
      (the triplet paradiddle)
      

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-04-16 21:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found