[Bioperl-l] Philosophy, BioPerl Object Creation
Hilmar Lapp
hlapp at gnf.org
Thu Mar 27 10:21:19 EST 2003
On Thursday, March 27, 2003, at 04:15 AM, Heikki Lehvaslaiho wrote:
> In related note: I wanted to inherit directly from a non-bioperl class
> and merge it with the rest of bioperl and came up with this:
>
> package Bio::WebAgent;
> use vars qw(@ISA);
> use strict;
> use LWP::UserAgent;
> use Bio::Root::Root;
>
> @ISA = qw(LWP::UserAgent Bio::Root::Root);
>
> sub new {
> my $class = shift;
>
> my $self = $class->SUPER::new();
> while( @_ ) {
> my $key = shift;
> $key =~ s/^-//;
> $self->$key(shift);
> }
>
> return $self; # success - we hope!
>
> }
>
> This actually faster than using _rearrange. In some of my tests old_new
> versus new_new was 19:14 seconds, sometimes less.
>
> Can anyone point out why this would be bad and perhaps show me a better
> way of doing the same thing.
Well, you don't pass on any parameters, so you rely on every class down
the tree having a method named identically to the parameter.
Would be nice if that were the case, but in bioperl it's definitely
not...
-hilmar
>
> -Heikki
>
>
>
>
> On Thu, 2003-03-27 at 11:32, Matthew Pocock wrote:
>>> argument list intact. Also, parameters may be used
>>> in more than one
>>> level in the hierarchy.
>>>
>>> -hilmar
>>
>> That seems a little rude. Can we get around this a bit
>> by accessing the parameter via an accessor? e.g.
>>
>> my $self = my_super->new(@_);
>> // pigColor was an argument but I need to know it to
>> // set myself up - use an accessor
>> my $pigColor = $self->pigColor();
>>
>> Matthew
>>
>>> --
>>>
>> -------------------------------------------------------------
>>> Hilmar Lapp email: lapp
>>> at gnf.org
>>> GNF, San Diego, Ca. 92121 phone:
>>> +1-858-812-1757
>>>
>> -------------------------------------------------------------
>>>
>>> _______________________________________________
>>> Bioperl-l mailing list
>>> Bioperl-l at bioperl.org
>>> http://bioperl.org/mailman/listinfo/bioperl-l
>>
>> __________________________________________________
>> Do You Yahoo!?
>> Everything you'll ever need on one web page
>> from News and Sport to Email and Music Charts
>> http://uk.my.yahoo.com
>> _______________________________________________
>> Bioperl-l mailing list
>> Bioperl-l at bioperl.org
>> http://bioperl.org/mailman/listinfo/bioperl-l
> --
> ______ _/ _/_____________________________________________________
> _/ _/ http://www.ebi.ac.uk/mutations/
> _/ _/ _/ Heikki Lehvaslaiho heikki at ebi.ac.uk
> _/_/_/_/_/ EMBL Outstation, European Bioinformatics Institute
> _/ _/ _/ Wellcome Trust Genome Campus, Hinxton
> _/ _/ _/ Cambs. CB10 1SD, United Kingdom
> _/ Phone: +44 (0)1223 494 644 FAX: +44 (0)1223 494 468
> ___ _/_/_/_/_/________________________________________________________
>
>
--
-------------------------------------------------------------
Hilmar Lapp email: lapp at gnf.org
GNF, San Diego, Ca. 92121 phone: +1-858-812-1757
-------------------------------------------------------------
More information about the Bioperl-l
mailing list