perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From do...@apache.org
Subject cvs commit: modperl-2.0/pod modperl_style.pod
Date Tue, 02 Jan 2001 19:56:09 GMT
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
  
  
  

Mime
View raw message