[Bioperl-l] bioperl API conventions

Hilmar Lapp hlapp at gmx.net
Fri Mar 3 18:13:11 EST 2006


Using combined getter/setters to me is primarily a style issue,
although the argument evaluation problem is a real one and in fact
we've been there.

Having said that, my point of view is basically, 1) we've learned the
lesson so might as well continue now that we deal with it, 2) perl is
not java (which is good and bad) and one might as well exploit the
difference as opposed to ignoring it, and 3) consistent API design is
better than inconsistent even if some of the 'new' flavors better
concur with Damian's or anybody else's style guides.

So, I like your last suggestion: stick with the consistent combined
getter/setter API for the interface and so long as you implement the
interface your implementation can delegate to whatever style model you
want.

    -hilmar


On 3/3/06, Rutger Vos <rvosa at sfu.ca> wrote:
> 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/
> ++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>
>


--
----------------------------------------------------------
: Hilmar Lapp -:- San Diego, CA -:- hlapp at gmx dot net :
----------------------------------------------------------



More information about the Bioperl-l mailing list