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

Matthew Pocock mrp@sanger.ac.uk
Wed, 15 Nov 2000 11:06:29 +0000

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:


_initialize($self, @args);



but this then begs the question - why have two functions instead of one (new + _initialize vs new).


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