Re: mini-quiz

Joshua Kronengold <[email protected]> Mon, 18 Jun 2007 23:52:14 -0400
Newsgroups gmane.comp.lang.perl.qotw.discuss
Message-ID <[email protected]>
On Mon, 18 Jun 2007 11:10pm, Ron Isaacson wrote:
> Joshua Kronengold wrote:
>>  I also don't much like testing string usefulness by truth (what if
>>  country is "0"?)
>
> Agreed! But...
>
>>  my $country = map +(/^(?:|gbr)$/ ? '' : uc),$card->country;
>
>>  $country &&= $country eq 'gbr' ? '' : uc "[$country]";
>
> Egad! You call those better?

the second one is -awful-.  Moastly because it replaces an unclear and 
confusing construct with a clearer but functionally identical and 
obscure construct -- it's clever, but not good.

The first one is much better.

I have the privledge of working at an organization that cultivates an 
intermediate (or better) knowledge of perl (which the first construct is 
solidly in the middle of, using nothing (expression-level map, regular 
expressions) an intermediate perl programmer should be completely 
comfortable with).  If I were writing for a basic or worse programmer to 
maintain, I might expand it, but that would make it harder for an 
intermediate-or-better perl programmer to maintain.

All things being equal, shorter -is- better.  Any phrase that goes much 
over a page becomes increasingly harder to comprehend -- and both 
"advanced" expressive features of a language like perl, and object 
oriented programming are techniques in furtherance of this (among 
others) goal -- to divide a proogramming task into byte sized chunks 
that are comprehensable and debuggable on their own.