[Bioperl-l] Re: Test writing

Hilmar Lapp hlapp at gmx.net
Thu Dec 29 12:48:43 EST 2005

On Dec 29, 2005, at 4:54 AM, Gabriel Valiente wrote:

> Thanks a lot.
>>> By the way, can anybody briefly explain why is it necessary to 
>>> include prefixes like
>>> my $common = $t1->Bio::Tree::Compatible::common_labels($t2);
>> I don't know why you would want to do that if $t1 is already a 
>> Bio::Tree::Compatible instance (or the module name as a string will 
>> do fine too).
> I see. The problem is that $t1 is not a Bio::Tree::Compatible instance 
> but a Bio::Tree::Tree instance.

Then why do you use the $t1-> notation to start with? You'd instead 

	my $common = Bio::Tree::Compatible->common_labels($t2);

> Perhaps the usual workaround in these situations is to add a dummy 
> Bio::Tree::Compatible->new method, that falls back on the 
> Bio::Tree::Tree->new method. The advantage would be to allow for a 
> more concise use of the Bio::Tree::Compatible methods.

If Bio::Tree::Compatible inherits from Bio::Tree::Tree then you don't 
need to implement new() unless you have some special setup to do during 
initialization. If you don't inherit from it, then do not fall back on 
some other class' new() method() either - otherwise at best you'll 
confuse perl or yourself about the inheritance structure.



BTW Please keep threads on the list. There are hundreds of people who 
might be able to help you.

> Please let me know what you think.
> Gabriel
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