You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl-cvs@perl.apache.org by do...@apache.org on 2001/01/02 20:56:09 UTC
cvs commit: modperl-2.0/pod modperl_style.pod
dougm 01/01/02 11:56:09
Added: pod modperl_style.pod
Log:
style guide
Revision Changes Path
1.1 modperl-2.0/pod/modperl_style.pod
Index: modperl_style.pod
===================================================================
=head1 NAME
mod_perl_style - style guide for mod_perl code
=head1 DESCRIPTION
This document
=head1 C code
mod_perl C code follows the Apache style guide:
http://dev.apache.org/styleguide.html
=head1 XS code
C code inside xs modules also follows the Apache style guide.
=head1 Perl code
Perl code also follows the Apache style guide, in terms of
indentation, braces, etc.
=head2 Global Variables
=over 4
=item avoid globals in general
=item avoid $&, $', $`
See Devel::SawAmpersand's README that explains the evilness. Under
mod_perl everybody suffers when one is seen anywhere since the
interpreter is never shutdown.
=back
=head2 Modules
=over 4
=item Exporting/Importing
Avoid too much exporting/importing (glob aliases eat up memory)
When you do wish to import from a module try to use an explict list or
tag whenever possible, e.g.:
use POSIX qw(strftime);
When you do not wish to import from a module, always use an empty list
to avoid any import, e.g.:
use IO::File ();
(explain how to use Apache::Status to find imported/exported
functions)
=back
=head2 Methods
=over 4
=item indirect vs direct method calls
Avoid indirect method calls, e.g.
don't say:
new CGI::Cookie
say:
CGI::Cookie->new
=back
=head2 Inheritance
=over 4
=item Avoid inherting from certain modules
Exporter
To void inherting B<AutoLoader::AUTOLOAD>
instead of this:
@MyClass::ISA = qw(Exporter);
use this:
*import = \&Exporter::import;
=back
=head2 Symbol tables
=over 4
=item %main::
stay away from main::
=back
Re: cvs commit: modperl-2.0/pod modperl_style.pod
Posted by Doug MacEachern <do...@covalent.net>.
On Wed, 17 Jan 2001, Ask Bjoern Hansen wrote:
> On 2 Jan 2001 dougm@apache.org wrote:
>
> > =item Avoid inherting from certain modules
> >
> > Exporter
> > To void inherting B<AutoLoader::AUTOLOAD>
> >
> > instead of this:
> >
> > @MyClass::ISA = qw(Exporter);
> >
> > use this:
> >
> > *import = \&Exporter::import;
>
> Why? To get less obscure error messages for methods that can't be
> found or are you being really absurd^Wenthusiastic with the memory
> savings? :)
why both, of course!
Re: cvs commit: modperl-2.0/pod modperl_style.pod
Posted by Doug MacEachern <do...@covalent.net>.
On Wed, 17 Jan 2001, Ask Bjoern Hansen wrote:
> On 2 Jan 2001 dougm@apache.org wrote:
>
> > =item Avoid inherting from certain modules
> >
> > Exporter
> > To void inherting B<AutoLoader::AUTOLOAD>
> >
> > instead of this:
> >
> > @MyClass::ISA = qw(Exporter);
> >
> > use this:
> >
> > *import = \&Exporter::import;
>
> Why? To get less obscure error messages for methods that can't be
> found or are you being really absurd^Wenthusiastic with the memory
> savings? :)
why both, of course!
Re: cvs commit: modperl-2.0/pod modperl_style.pod
Posted by Ask Bjoern Hansen <as...@valueclick.com>.
On 2 Jan 2001 dougm@apache.org wrote:
> =item Avoid inherting from certain modules
>
> Exporter
> To void inherting B<AutoLoader::AUTOLOAD>
>
> instead of this:
>
> @MyClass::ISA = qw(Exporter);
>
> use this:
>
> *import = \&Exporter::import;
Why? To get less obscure error messages for methods that can't be
found or are you being really absurd^Wenthusiastic with the memory
savings? :)
- ask (reading some of the last 25345345 while he really should be
sleeping, argh)
--
ask bjoern hansen - <http://ask.netcetera.dk/>
more than 70M impressions per day, <http://valueclick.com>
Re: cvs commit: modperl-2.0/pod modperl_style.pod
Posted by Ask Bjoern Hansen <as...@valueclick.com>.
On 2 Jan 2001 dougm@apache.org wrote:
> =item Avoid inherting from certain modules
>
> Exporter
> To void inherting B<AutoLoader::AUTOLOAD>
>
> instead of this:
>
> @MyClass::ISA = qw(Exporter);
>
> use this:
>
> *import = \&Exporter::import;
Why? To get less obscure error messages for methods that can't be
found or are you being really absurd^Wenthusiastic with the memory
savings? :)
- ask (reading some of the last 25345345 while he really should be
sleeping, argh)
--
ask bjoern hansen - <http://ask.netcetera.dk/>
more than 70M impressions per day, <http://valueclick.com>