[Bioperl-l] some not-so-good perl practice in bioperl

Hilmar Lapp hlapp at gnf.org
Mon Dec 22 11:34:43 EST 2003


On Monday, December 22, 2003, at 12:28  AM, Juguang Xiao wrote:

> It is no fault about it until this super or sub module have a method 
> with different name but use the same hash key.  So choosing the hash 
> key is not on your own ease. Here is the code in Section 12.7
>
> sub name {
>     my $self = shift;
>     my $field = __PACKAGE__ . "::name";
>     if (@_) { $self->{$field} = shift }
>     return $self->{$field};
> }
>

Good idea.

> Your getset generator may need to be updated. ;-)

Care to go ahead and do it?

> ##############################################
> 2) use vars (@ISA);
>
> This is copied from Chapter 31.
>
> 31.21. use vars
>
> use vars qw($frobbed @munge %seen);
>
>
> This pragma, once used to declare a global variable, is now somewhat 
> deprecated in favor of the our modifier.  The previous declaration  is 
> better accomplished using:
>
> our($frobbed, @munge, %seen);

I once started this and then was scolded for making bioperl 
incompatible with pre-5.005. But - don't we require 5.005 at minimum 
anyway meanwhile?


>
>   or even:
> our $frobbed = "F";
> our @munge = "A" .. $frobbed;
> our %seen = ();
>
> #########################################
> 3) auto getset, again
>
> I really cannot stand individual getset any more, after I read Section 
> 12.7. Do yourself a favor, read it, please. One year ago, I suggest to 
> use AUTOLOAD replace all getset methods. The idea was mercilessly 
> extinguish. Now I have big boss's support in his book. Anyone wants to 
> say anything? ;-) ( I do not mean to use AUTOLOAD again, but the rest 
> ways in that section should be discussed) Just do not stay your Perl 
> wisdom and braveness at high school, though your bioinformatics 
> achievement reach above the Ph. D height.
>

You had big boss' support at that time already. My stance on that is 
unchanged: I can't see how auto-loaded getter/setters make the code any 
better or increase coding productivity in any way. Especially once 
you're debugging. If you can't stand individual (uhm - in fact 
auto-generated by emacs lisp macros BTW) getter/setters then use 
auto-loading in your code, but don't be surprised if someone goes in 
and changes it to getter/setters for code clarity and better debugging.

	-hilmar

> I prefer the idea on Section 12.7.4. Generating Accessors with 
> Closures. It is listsub'able.
>
>
> my $0.02
>
> Juguang
>
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-l
>
-- 
-------------------------------------------------------------
Hilmar Lapp                            email: lapp at gnf.org
GNF, San Diego, Ca. 92121              phone: +1-858-812-1757
-------------------------------------------------------------




More information about the Bioperl-l mailing list