Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Should I leave behind beautiful code or readable code?

by grinder (Bishop)
on Mar 28, 2007 at 09:44 UTC ( #606960=note: print w/ replies, xml ) Need Help??


in reply to Should I leave behind beautiful code or readable code?

I beg to differ, but I find that neither beautiful nor readable. At the expense of sounding like an old fart, I would privilege readability over beauty, which is, of course, in the eye of the beholder anyway.

Especially for code you write for clients, I would shun dropping braces of maps (the speed optimisation is negligable) and implicit uses of $_. Spell it out:

return map {split( ' ', uc($_), 2)} @somearray;

This makes it pretty obvious that some sort of transform is being applied to @somearray, and that is what is being returned.

I used to omit return until the day I tried to return an anonymous hash reference...

• another intruder with the mooring in the heart of the Perl


Comment on Re: Should I leave behind beautiful code or readable code?
Download Code
Re^2: Should I leave behind beautiful code or readable code?
by jwkrahn (Monsignor) on Mar 28, 2007 at 12:24 UTC
    The very fact that you are using map says outright that some sort of transform is being applied to @somearray irregardless of how many parenetheses or braces you apply or whether $_ is explicitly used.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2015-07-06 08:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (70 votes), past polls