Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

(dws)Re: Perverse Unreadable Code

by dws (Chancellor)
on Apr 25, 2001 at 23:44 UTC ( #75588=note: print w/replies, xml ) Need Help??

in reply to Perverse Unreadable Code

I have also seen people doing horrors like putting if statements after the code to be excuted.

If the tools you've grown up with lack the descriptive power of Perl, you might well think that such a feature is a horror. But once you've done a bit of Perl and get used to it, you may find yourself cursing the lack of descriptive power of other tools.

To my eye   print "About to fetch $url\n" if $debug;
is more readable, and less disruptive to reading flow, than

if ( $debug ) { print "About to fetch $url\n"; }
As with any feature, this one can be abused. Which is why it's important to distinguish between the perversity of the tool and the perversity of the tool user.

Replies are listed 'Best First'.
(Maclir)Re: (dws)Re: Perverse Unreadable Code
by Maclir (Curate) on Apr 26, 2001 at 10:51 UTC

    There are advantages in the:

    if ( $debug ) { print "About to fetch $url\n"; }
    approach, mainly because if I want to throw a few more statements into the "if" block, I can do it simply.

    I also find having the code structured that way indicates clearly that a conditional is involved, and by seeing what the condition is, it can often provide an indication of why something is being done. For example:

    if ( $account_balance < '100.00' ) { print "Don't pay the loser any interest.\n"; }
    indicates we are dealing with low value accounts.

    But then again, we are talking subjective matters here. An alternative way, and in my mind just as readible, is:

    &calculte_interest($account_number) unless ($account_balance < '100. +00' );

    As a side line, I recall being told once "Fortran programmers can write fortran programs in any language."

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://75588]
[LanX]: Socrates was a Troll
[Your Mother]: It's very, very dangerous... Thinking that a group is intrinsically evil... buries the fact that all humans can be so deep that it starts to become likely they will be.
[Your Mother]: LanX++
[Corion]: (also the "troll for trolls sake" could seen be much like the "punk for punks beer")
[Your Mother]: I'm completely (historically anyway) a troll in real life. It's not fun online, you can't really win. :P
Happy-the-monk orders a Punk IPA.
[Your Mother]: Also, I'm too old to start fights with strangers anymore.
[LanX]: concentrating on omestic violence?
[LanX]: d
[Your Mother]: Open air violence. Or on campus.

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (22)
As of 2018-03-19 13:47 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (240 votes). Check out past polls.