[Bioperl-l] Bio::FeatureHolderI interface confusion

Hilmar Lapp hlapp at gmx.net
Thu Jun 19 12:49:17 EDT 2003


On Thursday, June 19, 2003, at 11:30  AM, Paul Edlefsen wrote:

> I don't know for sure, but I'm pretty sure that of the following two 
> options, the former is faster.  It's also, to me, prettier:

Both are equally ugly to me because both have more or less the same 
amount of added code that other than catching a rarely relevant 
condition only obfuscates your core business logic.

Imagine you'd have to wrap every setter in bioperl with this. My point 
is that from a practical viewpoint it is very rare that you only want 
to warn if the object doesn't permit set. In most cases, that will 
destroy your business logic and hence bailing out with an uncaught 
exception is appropriate.

>
> A)
> if( !$feature->isa( 'Bio::MutableFeatureHolderI' ) ) {
>  warn "Unable to add subfeature $subfeature: the parent feature 
> $feature does not allow the addition of subfeatures.";
> } else {
>  $feature->add_SeqFeature( $subfeature );
> }
>
> B)
> eval {
>  $feature->add_SeqFeature( $subfeature );
> }
> if( $@ ) {
>  warn "Unable to add subfeature $subfeature: the parent feature 
> $feature does not allow the addition of subfeatures.";
> }
>
> (Isn't eval() relatively inefficient?  I'd like to know, actually, 
> just for general knowing-of-important-things).

Supposedly not if it's within curly brackets, only if it's a quoted 
string. I may be wrong though, anybody who knows better please correct 
me.

	-hilmar

>
> :Paul
>
> Hilmar Lapp wrote:
>
>>
>> On Thursday, June 19, 2003, at 01:06  AM, Ewan Birney wrote:
>>
>>>>
>>>> Ok, here's a constructive suggestion
>>>>
>>>> (1) add mutability operations to the SeqFeatureI interface, as 
>>>> Hilmar
>>>> suggests.
>>>
>>>
>>> I *really* dislike mutability to interfaces. Certain implementations 
>>> just
>>> can't do it. Mutability is an implementation specific case. Or we 
>>> need to
>>> split into immutable and mutable interfaces.
>>>
>>>
>>
>> I agree with certain implementations not being able to support 
>> mutability. Splitting into mutable and immutable interfaces does 
>> contribute to the explosion of interfaces though, and quite honestly 
>> in 90% of use cases you need mutability anyway, and literally all 
>> modules in bioperl are mutable.
>>
>> What about allowing implementors to throw an exception on set if they 
>> don't support mutability?
>>
>>     -hilmar
>>
>
> -- 
> +-----O------------------------------------+
> |    o-o     Paul T. Edlefsen
> |    o---o   Computational Biologist
> |  o----o    mailto:paul at systemsbiology.org
> | O----O     Institute for Systems Biology
> | 0--o       1441 North 34th Street
> |   O        Seattle, Washington 98103-8904
> |  o-o       callto:1-206-732-1336
> +-o---o------------------------------------+
>
>
>
>
>
>
-- 
-------------------------------------------------------------
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