Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
The second line is obviously too much for me, because it does two things in one statement. By one statement, I mean, is terminated by statement terminator, semicolon (;) in this case (explicitly or otherwise). This might help a little,
$country = $country eq 'gbr' ? '' : uc "[$country]" if $country;
Two lines, but it's also deceptive, and it's still one statement. So what is "one line of code"? Physically terminated by newline character?

Ease of read vs clear to reflect business logic should not happen. They are not mutually exclusive, they should happen at the same time. I think, however, that if a code is clear to reflect business logic, it's easy to read, but not vice versa.

Well, If I had to rewrite the code (not the overall logic or even redesign the flow), I would write:

if ($country) { $country = $country eq 'gbr' ? '' : uc "[$country]"; }
But I prefer,
my $country = ''; my $code = $card->country; $country = "[\U$code]" unless $code eq 'gbr';

Update: I should add that the third line potentially generates warning, but I assumed that the country() method always returns defined value. And yes, I agree that the comparisson value (gbr in this case), should be abstracted out.

Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!

In reply to Re: How Much Is Too Much (on one line of code)? by naikonta
in thread How Much Is Too Much (on one line of code)? by Ovid

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, 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
  • 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (5)
    As of 2018-07-22 09:08 GMT
    Find Nodes?
      Voting Booth?
      It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

      Results (453 votes). Check out past polls.