Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

by pdcawley (Hermit)
on Mar 29, 2007 at 23:07 UTC ( [id://607377]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Should I leave behind beautiful code or readable code?
in thread Should I leave behind beautiful code or readable code?

It's not the chained maps that are problematic. It's the magic use of uc buried in the arguments to split, coupled with the use of map EXPR, ARRAY instead of map {...} ARRAY

Personally, I'd prefer to see:

return map { split / /, uc $_, 2 } @somearray

I could argue both sides on the explicit return, but I come down in favour of being explicit because you're producing what Kent Beck calls an 'interesting return value'. The use of a block rather than a simple expression clues the reader in to the fact that the call to split isn't as simple as it looks. The explicit $_ argument to uc is there for clarification too.

Frankly, I don't care about the maintainance programmer who's going to be here when I leave, I'm more worried about the psychopath who knows where I live. By paying the price of a few extra characters I get code that I know I won't be scratching my head over tomorrow, and that's the kind of peace of mind I like.

But, if you want to play golf, map{split/ /,uc,2}@somearray looks like a winner.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-26 08:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found