in reply to Re: RFC: App::SFDC
in thread RFC: App::SFDC

Do you think it's more that just a stylistic/opinion choice? My feeling is that creating intermediate variables and modifying them is less clear because it requires keeping track of more variables over more statements and lines.

Replies are listed 'Best First'.
Re^3: RFC: App::SFDC
by Monk::Thomas (Friar) on Jul 15, 2015 at 11:25 UTC

    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.

      I have to agree that Monk::Thomas' rewrite is quite a bit easier to understand.