[Bioperl-l] parameter/method naming conventions
Hilmar Lapp
hlapp@lj.gnf.org
Tue, 1 Oct 2002 10:45:42 -0700
I think it is convention by now to start parameter names with a
dash. Also, the new _re_arrange() implementation uses this to
determine whether you passed named arguments or not.
You can still use any other convention for internal calls. Also, you
can allow both forms if you can support this yourself. E.g. if you
require parameters to be always named,
my $i = 0;
@args = map { $i++ % 2 ? $_ : '-'.$_; } @args;
maps (should map, not tested :) dash-less to dash-ful names,
provided there are names.
My personal opinion on auto-generating method names by whatever
method is that for serious code it saves you only about 1-3% of the
total coding, testing, and documentation time ... YMMV though.
-hilmar
On Monday, September 30, 2002, at 09:43 PM, Allen Day wrote:
> Hi All,
>
> Hilmar has been cleaning up the get/set method names to make them
> consistent across the Bio::* classes, and I was wondering what can
> be done
> about parameter conventions, such as those passed to new(). It
> looks like
> some of the modules are using non-dashed parameters:
>
> Class->new(a=>1,b=>2)
>
> some are using dashed parameters:
>
> Class->new(-a=>1,-b=>2)
>
> and some can accept either. It isn't always clear to me what form
> to pass
> without poring over the manpage for the details.
>
> How do people feel about stripping out leading dashes? I wasn't too
> unhappy with this until I've started using
> Class::MakeMethods::Emulator::MethodMaker to (among other things)
> create
> all my get/set methods.
>
> perl -e "sub -function(){}" #error
>
> Unfortunately, method names can't start with dashes. One of the nice
> things with C::M::E::M is you can just pass a list of fields for which
> get/set methods will be created, and the method names can conform to
> whatever convention we like based on the field name.
>
> -Allen
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l@bioperl.org
> http://bioperl.org/mailman/listinfo/bioperl-l
>
--
-------------------------------------------------------------
Hilmar Lapp email: lapp at gnf.org
GNF, San Diego, Ca. 92121 phone: +1-858-812-1757
-------------------------------------------------------------