It is basically a stylistic choice, but I think it improves the readability of the code a lot. At least to me. I picked this code example because at first glance I simply saw 'stuff', then while looking at it there were 'revelation'-like experiences. Oh! It's a function call! Oh! It's using a ternary operator to build a conditional argument set. Oh! The conditional is just there to help debugging.

I rewrote the code to make these 3 different aspects more visible and make it easier to mentally skip parts that are probably not relevant to spotting bugs, e.g. the debug conditional.

Generally I try to format the code in a way that minimizes the mental effort and the time required to recognize the building blocks. Hopefully this helps to reduce the 'TL;DR'-effect when reading / scanning over it and helps to spot possible bugs more easily. That's also the reason why I try to avoid the ternary operator in complicated statements. Sure it's convenient, but '?' is a lot less visibly distinct then 'if ('. In your case I was even able to drop the 'else' branch, because it didn't have any purpose besides satisfying the syntax.


In reply to Re^3: RFC: App::SFDC by Monk::Thomas
in thread RFC: App::SFDC by ali0sha

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.