Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Problems? Is your data what you think it is?

Comment on

then the subroutine probably has almost no code in it at all, and the solution is to inline the tiny amount of code in the subroutine and remove the calling overhead entirely.

Sure, you could do that, but are you really going to allow all the callers of your objects to access their attributes directly rather than going through getters?

Little bits add up! Here a 25% penalty just to satisfy two pointless P::C rules:

#! perl -slw use strict; use Benchmark qw[ cmpthese ]; our $o = bless { X=>1 }, 'main'; sub getX1{ my $self = shift; return $self->{X}; } sub getX2{ return $_[0]->{X}; } sub getX3{ $_[0]->{X}; } cmpthese -1, { A=> q[ my $x = $o->getX1(); ], B=> q[ my $x = $o->getX2(); ], C=> q[ my $x = $o->getX3(); ], }; __END__ C:\test>junk19 Rate A B C A 1441709/s -- -11% -20% B 1611352/s 12% -- -10% C 1797147/s 25% 12% --

And that is just one level deep. Imagine (or test) the affect of calling a method that itself needs to call 2 or 3 getter() from one of its sub objects.

The penalties, for what are purely cosmetic affectations, add up.

In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^14: The Most Essential Perl Development Tools Today (negative) by BrowserUk
in thread The Most Essential Perl Development Tools Today by Tommy

and:  <code> code here </code>

  • Please read these before you post! —
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (7)
    As of 2014-03-16 18:08 GMT
    Find Nodes?
      Voting Booth?

      Have you used a cryptocurrency?

      Results (331 votes), past polls