[Bioperl-l] 0.7 release: Bio::Root::* classes

Ewan Birney birney@ebi.ac.uk
Wed, 15 Nov 2000 11:08:13 +0000 (GMT)


On Wed, 15 Nov 2000, Matthew Pocock wrote:

> 
> 
> Ewan Birney wrote:
> 
> > On Tue, 14 Nov 2000, Jason Stajich wrote:
> >
> > > Comments on a better way to handle this?
> >
> > perl does not handle this great, but you can write a new function in the
> > subclass which calls the new in the base class with arguments and then
> > reblesses into the subclass.
> >
> > not pretty, but nor is _initialize
> >
> 
> The rebless is realy the best oo way to do this as during construction
> time, an object should only be able to execute the methods & access
> the fields of the class being initialized and all parent classes, not
> sub-class methods etc. - repeated blessing means that this is what you
> get. It is generaly realy *bad* for a base-class to call overridden
> methods in a constructor, as these may access uninitialized state of
> the sub-class. There would be nothing wrong with new calling
> _initialize after re-blessing, as long as _initialize did not chain
> onto SUPER::_initialize, and it was invoked as a function not a
> method:
> 
> e.g.
> 
> _initialize($self, @args);
> 
> not
> 
> $self->_initialize(@args);
> 
> but this then begs the question - why have two functions instead of
> one (new + _initialize vs new).


I tend to agree with matthew here, though if people felt that keeping
intialize was better than multiple new/rebless cycles then I would be ok.
I think they are basically equivalent and multiple new's is more
"standard"

what does damain conway or another OO perl guru say about this...






> 
> Matthew
> 
> >
> > -----------------------------------------------------------------
> > Ewan Birney. Mobile: +44 (0)7970 151230, Work: +44 1223 494420
> > <birney@ebi.ac.uk>.
> > -----------------------------------------------------------------
> >
> > _______________________________________________
> > Bioperl-l mailing list
> > Bioperl-l@bioperl.org
> > http://bioperl.org/mailman/listinfo/bioperl-l
> 
> 

-----------------------------------------------------------------
Ewan Birney. Mobile: +44 (0)7970 151230, Work: +44 1223 494420
<birney@ebi.ac.uk>. 
-----------------------------------------------------------------