[Bioperl-l] bioperl API conventions

Rutger Vos rvosa at sfu.ca
Fri Mar 3 16:47:51 EST 2006


Hi all,

I've noticed that many bioperl objects don't separate getters from 
setters, e.g.:

my $branchlength = $node->branchlength; # now it's a getter
$node->branchlength($branchlength); # now it's a setter

Is this approach carved in stone? Or could one contribute objects to the 
project that do:

my $branchlength = $node->get_branchlength;
$node->set_branchlength($branchlength);

To me (and, apparently, to Damian Conway, see "perl best practices" :) 
the latter approach is better, as it takes away some ambiguity, 
especially w.r.t setting false-but-defined values (bugs could emerge 
where arguments are erroneously tested for truth rather than 
definedness) and resetting fields to undef.

Also, is it okay to have separate getters and setters in your own 
objects, but implement interfaces that do the combined get/setter thing 
using aliasing?

Thanks,

Rutger

-- 
++++++++++++++++++++++++++++++++++++++++++++++++++++
Rutger Vos, PhD. candidate
Department of Biological Sciences
Simon Fraser University
8888 University Drive
Burnaby, BC, V5A1S6
Phone: 604-291-5625 
Fax: 604-291-3496
Personal site: http://www.sfu.ca/~rvosa
FAB* lab: http://www.sfu.ca/~fabstar
Bio::Phylo: http://search.cpan.org/~rvosa/Bio-Phylo/
++++++++++++++++++++++++++++++++++++++++++++++++++++




More information about the Bioperl-l mailing list