[Bioperl-l] Re: Automatic generation of set and get methods
Steven Lembark
lembark@wrkhors.com
Fri, 15 Nov 2002 14:17:28 -0600
>> * Documentation template could be autogenerated
>
> Macro does this.
Only if we insist that everyone use your editor and macro
set.
>
>> * Reduces amount of routine code within a module so you
>> can focus on the
>> business logic.
>
> Macro does this. If it's not boilerplate someone's got to code it anyway.
But they do it once and the result is consistent. Using your macro
may be nice in your editor, but still leaves you open to typos
while using the macro. You also pointed out that using the macro
does nothing to help relieve the drudgery of filling in templates.
For seriously trivial accessor/mutator methods it may be sufficient
to document the object's fields and their types once in the main
pod and leave it at that.
>> * Code is less explicit; can't see all methods when
>> reading module source
>> * Can't validate data when setting (but see below)
>> * Runtime bugs within autogenerated code harder to track down
>> * Performace hit (maybe, not sure about this)
>
> Allegedly method calls are a performance hit in perl. That's what we've
> been trying to reduce to make the parsers faster. Every method call is a
> performance hit because there is apparently no efficient virtual method
> lookup table.
The first time a method is called there is a lookup to
find it. After that the result is cached. Unless someone
explicitly plays with that portion of the symbol table
further use of the method is no worse than a subroutine
call. If an AUTOLOAD installs the method and does a goto
then the method will be called at full speed from then on.
Part of Perl's flexability in handling these things is the
ability to modify the symbol table on the fly. Caching will
normally save most of this expense. Overuse of AUTLOAD with
no subroutine installed will be seriously expensive.
--
Steven Lembark 2930 W. Palmer
Workhorse Computing Chicago, IL 60647
+1 800 762 1582