Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: How Much Is Too Much (on one line of code)?

by talexb (Canon)
on Jun 18, 2007 at 18:31 UTC ( #621849=note: print w/replies, xml ) Need Help??

in reply to How Much Is Too Much (on one line of code)?

Without wanting to be influenced by the other comments, my opinion is that it's too much, without braces or a comment to make it clear in what order things happen, or why they are happening.

Without the braces I probably have to .. no, I have to look up what the precedence order is, or try it in the debugger. Yes, certainly after developing in Perl for ten years I should probably know that, but I don't. Also, the assignment to $country followed immediately by a re-assignment to $country isn't a style I love.

OK, (after trying it in the debugger) it does do the ternary first and the if statement within that .. that's what I expected.

To answer your question, no, this code is not clear.

Was there a comment explaining the business logic? The left side of my brain suggests ..

# Blank country field if Great Britain, otherwise upper # case country name within square brackets. Leave field # empty if country is undefined.
.. but the right side of my brain prevails, and provides a much better comment:
# Since we're mailing from GBR, only display the country # if it's not GBR, and leave a blank country field blank.

Above all, strive for clarity.

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2018-09-20 08:25 GMT
Find Nodes?
    Voting Booth?
    Eventually, "covfefe" will come to mean:

    Results (173 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!