Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I find all of the justifictions in support of option 3 over option 2 utterly bogus.

  • The condition is more important than the action.

    Rubbish. The program doesn't work if the action isn't taken when it should be; nor if it is, when it should not.

  • People "won't notice the condition stuck on the end".

    Then they should not be programmers.

    In my experience, the reverse is far more frequent. People read the condition, and assume the action conditional upon it.

    There is no excuse for not reading the code properly. Like reading "To be or not to be...", but never reading on.

  • That it is "quicker to modify" if the action needs to expand.

    If the time required to revert a post-fix condition, to prefix with block is a significant part of the time taken to make the change, then I suggest insufficient thought has been applied to considering the change in the first place.

  • (English) speech patterns favour option 3.

    "Beat that if you can"; "Try that if you dare"; "Help yourself if you're hungry"; "Get in if you're coming".

Justifictions all.

Personally, I use option 1 when I have a simple condition/action pair with a postfix for or while in performance critical loops.

Otherwise I use option 2.

I see no advantage in option 3, beyond the need for a else. And I'm, as likely as not to code that as:

condition and action1() or action2();

But then, I've been used to postfix conditions and loops--including nested postfixes, which I was pleased to see made it into Perl6--since Basic Plus days, 25+ years ago.

I wouldn't mandate them upon anyone, but I abhor them being demonised.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re: A matter of style: how to perform a simple action based on a simple condition? by BrowserUk
in thread A matter of style: how to perform a simple action based on a simple condition? by muba

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (13)
    As of 2014-12-18 13:06 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (51 votes), past polls