[Bioperl-l] For CVS developers - throw_not_implemented

Chris Fields cjfields at uiuc.edu
Wed May 31 21:40:22 UTC 2006


I think, as long as it's reflected in the docs that something doesn't work
(hasn't been implemented) then there's no problem.  It's when the docs are
misleading that we run into problems.  

The sticking point lies with some classes, such as IO classes (like SeqIO,
or Restrict::IO, with read and write methods) where the IO base class
specifies that it is possible to read and write a particular format but the
actual implementation varies according to whether or not the derived class
overrides the base or interface method (in other words, 'doesn't work as
advertised' only in specific circumstances).  I don't know how to solve this
issue except to add in the docs that specific formats don't implement
write() methods.  

Personally, I haven't had an issue with it and it probably makes no
difference, but I think it needs to be pointed out.  The most extreme I ran
into was Bio::Restriction::IO, which had 3 out of 4 plugin modules that
didn't implement the write() method but left this in the synopsis in POD:

    use Bio::Restriction::IO;

    $in  = Bio::Restriction::IO->new(-file => "inputfilename" ,
                                     -format => 'withrefm');
    $out = Bio::Restriction::IO->new(-file => ">outputfilename" ,
                                     -format => 'bairoch');
    my $res = $in->read; # a Bio::Restriction::EnzymeCollection
    $out->write($res);

  # or

  #    use Bio::Restriction::IO;
  #
  #    #input file format can be read from the file extension (dat|xml)
  #    $in  = Bio::Restriction::IO->newFh(-file => "inputfilename");
  #    $out = Bio::Restriction::IO->newFh('-format' => 'xml');
  #
  #    # World's shortest flat<->xml format converter:
  #    print $out $_ while <$in>;

None of this code works; in fact, no XML parser even exists for these IO
classes!  Bio::AlignIO also has a few as well (maf and Stockholm formats
don't write).

Chris


> -----Original Message-----
> From: Hilmar Lapp [mailto:hlapp at gmx.net]
> Sent: Wednesday, May 31, 2006 4:22 PM
> To: Chris Fields
> Cc: lstein at cshl.edu; bioperl-l at lists.open-bio.org; 'Heikki Lehvaslaiho'
> Subject: Re: [Bioperl-l] For CVS developers - throw_not_implemented
> 
> 
> On May 31, 2006, at 4:40 PM, Chris Fields wrote:
> 
> > What about modules that have 'throw_not_implemented' statements
> > present?
> 
> Those are often if not always legitimate - the problem are those that
> don't have them but fail to override an inherited interface or
> abstract method.
> 
> If something is not implemented what is the better way to express
> this other than throwing an exception? (and if it's not an interface
> or abstract base class, saying so in the documentation)
> 
> 	-hilmar
> 
> --
> ===========================================================
> : Hilmar Lapp  -:-  Durham, NC  -:-  hlapp at gmx dot net :
> ===========================================================
> 
> 
> 





More information about the Bioperl-l mailing list