Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: Two simple code style advice questions (tye)

by Tux (Monsignor)
on Jan 18, 2013 at 16:17 UTC ( #1014080=note: print w/ replies, xml ) Need Help??


in reply to Re: Two simple code style advice questions (tye)
in thread Two simple code style advice questions

But I've come to find ternaries to often be less quick/easy to read than something like:

I am with BrowserUK here, and I am happy to see you are using the "I find" instead of the way to often used "it is better to" (here in the monastery), as many idioms that are easy to parse by person A causes headaches to person B.

Personally I would try to avoid statement modifiers to any cost. I hate them. They make me read code exactly opposite of what the author meant.

I have no trouble reading (nested) ternary operations. Maybe too used to those from doing C.

You also doing java? Where 42 == $n is quite often preferred over $n == 42 because of "string".equals ($n) implies NULL checks.


Enjoy, Have FUN! H.Merijn


Comment on Re^2: Two simple code style advice questions (tye)
Select or Download Code
Re^3: Two simple code style advice questions (short)
by tye (Cardinal) on Jan 18, 2013 at 17:44 UTC
    You also doing java?

    Nope. I started trying out "42 == n" in C a long time ago to avoid accidentally writing "if( n = 42 )".

    In this case, I wrote "42 == $n" as I find "42" to be the much more interesting part of the expression. I prefer to put shorter things and more interesting things first to speed parsing.

    - tye        

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2014-08-01 07:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (257 votes), past polls