[Koha-bugs] [Bug 13240] advanced_notices.pl contains code obfuscation

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed Nov 19 18:45:53 CET 2014


http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=13240

M. Tompsett <mtompset at hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mtompset at hotmail.com

--- Comment #4 from M. Tompsett <mtompset at hotmail.com> ---
(In reply to Frédéric Demians from comment #3)
> You replace:
> 
>   my $digest = $due_digest->{$upcoming->{'borrowernumber'}} ||= {};
>   $digest->{email} ||= $from_address;
>   $digest->{count}++;
> 
> With:
> 
>   $due_digest->{$upcoming->{borrowernumber}}{email} = $from_address;
>   $due_digest->{$upcoming->{borrowernumber}}{count}++;
> 
> But why exactly?

Why create variables when you don't need to? Are we so desperate for speed that
much that we want to lose simple readability?


> The first syntax is Perlish, with ||=, but not to the point
> to be unreadable.

To those unfamiliar with Perl "pointers" (for a lack of a better word, since it
is a NEW syntax to me), it is unreadable. Once you realize that $digest
"points" to what $due_digest->{$upcoming->{'borrowernumber'}} points to, then
it does make sense.


> And the second syntax uses autovivification which isn't
> that readable either.

Actually, autovivification is far more readable and understandable than using a
secondary pointer to fill in another data structure.


> And the second syntax uses $h->{}{} which isn't so
> good: $h->{}->{} should be preferred, imho.

I agree with Frédéric Demians on this, though only because it makes the change
more apparently equal to me, not because it actually generates a better or
different data structure.

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list