[Bioperl-l] SeqIO parsing

Hilmar Lapp hlapp@gnf.org
Tue, 24 Sep 2002 15:30:41 -0700


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 ...

	-hilmar

On Tuesday, September 24, 2002, at 03:20 PM, Allen Smith wrote:

> On Sep 24,  2:49pm, Hilmar Lapp wrote:
>> On Tuesday, September 24, 2002, at 09:01 AM, Ewan Birney wrote:
>
>>>
>>> this scheme in my mind has one *SERIOUS* gotcha. People *have* to 
>>> write
>>> their @ISA's with their implementation tree *first* and their 
>>> interface
>>> inheritance second. Is this ok with people?
>>>
>>
>> It should be the style everyone employs already. Otherwise you set
>> yourself up for trouble anyway (how would you avoid the interface
>> method stub that throws an exception from being invoked if you put
>> the interface first?).
>
> I'm wanting to make sure that I (and hopefully others!) understand what
> you're meaning here. So, in creating a module, the layout should be
> something like:
>
> In Bio::Matrix::Substitution:
>
> 	use Bio::Root::Root;
> 	use Bio::Root::IO;
> 	use Bio::Matrix::SubstitutionI;
>
> 	[...]
>
> 	@ISA = qw(Bio::Root::Root Bio::Root::IO Bio::Matrix::SubstitutionI);
>
> In Bio::Matrix::SubstitutionI:
>
> 	use Bio::Root::RootI;
>
> 	[...]
>
> 	@ISA = qw(Bio::Root::RootI);
>
> 	[bunch of functions, _not_ including 'new' (or the similar 'newIO'),
> 	which all look something like:
>
> 		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 - it would
> 	be only for optional functions, then?]
>
> This at least seems to work in my preliminary testing, but I'm 
> afraid that I
> find the whole implementation/interface distinction - actually, object
> orientation in general - difficult to get, so I'm nervous about this...
>
> 	Thanks,
>
> 	-Allen
>
> --
> Allen Smith			http://cesario.rutgers.edu/easmith/
> September 11, 2001		A Day That Shall Live In Infamy II
> "They that can give up essential liberty to obtain a little temporary
> safety deserve neither liberty nor safety." - Benjamin Franklin
>
--
-------------------------------------------------------------
Hilmar Lapp                            email: lapp at gnf.org
GNF, San Diego, Ca. 92121              phone: +1-858-812-1757
-------------------------------------------------------------