[Bioperl-l] SeqIO parsing

Tim Bunce Tim.Bunce@pobox.com
Fri, 27 Sep 2002 12:25:37 +0100


On Tue, Sep 24, 2002 at 03:30:41PM -0700, Hilmar Lapp wrote:
> All your code is correct.
> 
> Interface definitions have several advantages:
> 
> - the interface clearly tells implementors what they have to do 
> (implementation by contract)
> - the interface clearly tells clients what to at least expect 
> without distraction by implementation-specific bells and whistles
> - implementations can offer lots of things without blurring what is 
> mandatory
> - testing once for $obj->isa("MyInterfaceI") substitutes for a whole 
> bunch of can(...) tests
> - makes type-checking easy and readable
> 
> No claim for completeness ...

But all good stuff.

> >
> >		sub string {
> >			my $self = shift;
> >			$self->throw_not_implemented();
> >		}
> >	I do have the problem with this that it appears to lessen the
> >	utility of $object->can('something'), as I understand it

If this became an issue then one approach would be to replace the
sub definition with:

	*string = \&Bio::Root::RootI::throw_not_implemented;

which would have the same effect (but use less memory).
You'd then be able to write code like

  if ($object->can('something') == $object->can('throw_not_implemented')) { ... }

And/or abstract that logic into a RootI method.

Tim.