>>>>> "MGS" == Michael G Schwern <schwern@pobox.com> writes:
>> even better than just be a poorly written constructor is that it is
>> inside a 'factory' module that is inherited by 80 other modules!!
MGS> If that's an example of "poorly written" code in your project,
MGS> can I come work there? It at least gets it right, if verbosely.
well it is a live system so it must be 'right'. i was hired to review it
and the double copy of the hash data is what bothers me. as this is
called zillions of times by all those modules it is a quick and easy
speedup.
and they are hiring more outsource indians so you won't be contacted. :(
MGS> sub new {
MGS> my $class = shift;
MGS> return bless( {@_}, $class );
MGS> }
my clean version is:
sub new {
my ( $class, %self ) = @_ ;
return bless \%self, $class ;
}
i don't like using shift for args if i can help it.
MGS> sub new {bless{@_[1..$#_]},shift}
that is the same as my shorter golf answer. maybe i counted mine wrong.
MGS> sub new {$a=shift;bless{@_},$a}
MGS> 21. And it's even strict clean. :)
that is nice. the other replies beat it though!
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
Thread Previous
|
Thread Next