[Bioperl-l] question of seq() method of Bio::DB::GFF and Bio::PrimarySeq

Chris Fields cjfields at illinois.edu
Sun Jan 30 14:53:47 UTC 2011


On Jan 30, 2011, at 6:10 AM, Adam Sjøgren wrote:

> On Fri, 28 Jan 2011 13:57:25 +0700, chirag wrote:
> 
>> Objects in Bioperl are References ,generally  hash references,where keys are
>> attributes like name and source of sequence
> 
>> So to get values , You need to Deference them to fetch values stored at the
>> memory location.
> 
>> my $hash_value=$hash_ref->{'some_key'};
> 
> Generally the object provides methods (accessors) for all the
> information that it wants to expose.
> 
> Bypassing that and going directly into the internal datastructure of the
> object ("breaking encapsulation") can be okay when you are debugging the
> code implementing the objects, but it is good practise to respect and
> use the interfaces otherwise (the internals of the object might change
> while the documented interface stays the same).
> 
> So I would say: Look up the methods to call in the documentation and
> avoid accessing in the internal representation of the objects directly.
> 
> 
>  Best regards,
> 
>    Adam
> 
> -- 
>                                                          Adam Sjøgren
>                                                    adsj at novozymes.com

The other aspect of this: we do not guarantee those hash keys will stay the same, or even be accessible.  What happens if we decide to switch to Moose, which does not store attributes the same way?

We only support the indicated API, relying on anything else is a ticking time bomb.

chris



More information about the Bioperl-l mailing list