Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^3: How to write better code?

by imp (Priest)
on Dec 04, 2006 at 17:20 UTC ( #587704=note: print w/replies, xml ) Need Help??

in reply to Re^2: How to write better code?
in thread How to write better code?

Your implementation using map instead of foreach is slightly more readable, but will be more cumbersome to maintain and debug if additional parsing is required. It is likely a short-term win that will result in a comment block that is larger than the code after a few upgrades are made.

Another weakness of using map for this is that CGI allows a parameter to have multiple values, but the code you provided will only use the last value.

Replies are listed 'Best First'.
Re^4: How to write better code?
by johngg (Abbot) on Dec 04, 2006 at 20:21 UTC
    If the task becomes more complex then I would almost certainly rewrite the code with more explicit control structures and descriptive variable names rather than jump through hoops making the map fit. I am only throwing away one line, when all's said and done.

    I agree with your comment about CGI and said as much at the top of my post, which was more a comment on the code snippet itself and it's legibility rather than it's suitability for parsing CGI.



Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://587704]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2018-05-23 09:40 GMT
Find Nodes?
    Voting Booth?