[Bioperl-l] naming conventions
Hilmar Lapp
hlapp@gnf.org
Sat, 12 Oct 2002 14:24:34 -0700
(changed the subject to be proper)
On Saturday, October 12, 2002, at 09:26 AM, Ewan Birney wrote:
> >
> > Excellent - that's very similar to how we're moving, right? The
> > difference is that we have get_XXXXs which returns an array, and
> > get_all_XXXXs, which returns a possibly flattened array (e.g., for
> > SeqI this would be get_SeqFeatures() instead of top_SeqFeatures(),
> > and get_all_SeqFeatures() instead of all_SeqFeatures().
> >
> > Ewan what's the plan for this distinction in Ensembl?
>
> I am not the person with the definitive answer - I have cc'd in
> Arne and
> Graham who do have the definitive answer - my reading of it is that we
> have the following conventions:
>
>
> get_all_XXXXX = returns a list of XXXX
>
> get_XXXXX = returns a single scalar of XXXX
>
> fetch_XXXX_by_YYYYY = is a database adaptor specific convention,
> returning one XXXX by criteria YYYY
Hm. When I rewrote the bioperl-db adaptors I decided to closely
follow the already existing J2EE conventions, which makes life
easier for people having to deal with both. So, there's now
find_by_primary_key
find_by_unique_key
find_by_query
find_by_association
in every adaptor. An adaptor adapts only a specific interface, hence
it is clear which type of object it returns. With this naming you
wouldn't know though whether to expect a list or a single object
(but you could treat them all as returning a list in perl).
Just my $0.02.
-hilmar
--
-------------------------------------------------------------
Hilmar Lapp email: lapp at gnf.org
GNF, San Diego, Ca. 92121 phone: +1-858-812-1757
-------------------------------------------------------------