cvs: peardoc /en/chapters standards.xml

From: Date: Thu, 10 Apr 2008 13:56:28 +0000
Subject: cvs: peardoc /en/chapters standards.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-10645@lists.php.net to get a copy of this message
saltybeagle Thu Apr 10 13:56:28 2008 UTC Modified files: /peardoc/en/chapters standards.xml Log: Apply patch from Chuck Burgess - improves explanation of public member variables, public methods, global functions, constants. http://cvs.php.net/viewvc.cgi/peardoc/en/chapters/standards.xml?r1=1.64&r2=1.65&diff_format=u Index: peardoc/en/chapters/standards.xml diff -u peardoc/en/chapters/standards.xml:1.64 peardoc/en/chapters/standards.xml:1.65 --- peardoc/en/chapters/standards.xml:1.64 Tue Mar 11 16:31:06 2008 +++ peardoc/en/chapters/standards.xml Thu Apr 10 13:56:28 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1" ?> -<!-- $Revision: 1.64 $ --> +<!-- $Revision: 1.65 $ --> <chapter id="standards"> <title>Coding Standards</title> @@ -695,6 +695,32 @@ <sect1 id="standards.naming"> <title>Naming Conventions</title> <sect2> + <title>Global Variables and Functions</title> + <para> + If your package needs to define global variables, their names + should start with a single underscore followed by the package + name and another underscore. For example, the PEAR package uses + a global variable called $_PEAR_destructor_object_list. + </para> + <para> + Global functions should be named using the <quote>studly caps</quote> + style (also referred to as <quote>bumpy case</quote> or <quote>camel + caps</quote>). In addition, they should have the package name as + a prefix, to avoid name collisions between packages. The initial letter + of the name (after the prefix) is lowercase, and each letter that + starts a new <quote>word</quote> is capitalized. An example: + <informaltable> + <tgroup cols="1"> + <tbody> + <row> + <entry><simpara>XML_RPC_serializeData()</simpara></entry> + </row> + </tbody> + </tgroup> + </informaltable> + </para> + </sect2> + <sect2> <title>Classes</title> <para> Classes should be given descriptive names. Avoid using abbreviations @@ -716,23 +742,20 @@ </para> </sect2> <sect2> - <title>Functions and Methods</title> + <title>Class Variables and Methods</title> <para> - Functions and methods should be named using the - <quote>studly caps</quote> style (also referred to as - <quote>bumpy case</quote> or <quote>camel caps</quote>). - Functions should in addition have the package name as a prefix, - to avoid name collisions between packages. The initial letter of - the name (after the prefix) is lowercase, and each letter that - starts a new <quote>word</quote> is capitalized. Some examples: + Class variables (a.k.a properties) and methods should + be named using the <quote>studly caps</quote> style (also referred + to as <quote>bumpy case</quote> or <quote>camel caps</quote>). + Some examples (these would be <quote>public</quote> members): <informaltable> <tgroup cols="4"> <tbody> <row> + <entry><simpara>$counter</simpara></entry> <entry><simpara>connect()</simpara></entry> <entry><simpara>getData()</simpara></entry> <entry><simpara>buildSomeWidget()</simpara></entry> - <entry><simpara>XML_RPC_serializeData()</simpara></entry> </row> </tbody> </tgroup> @@ -747,9 +770,9 @@ <tgroup cols="3"> <tbody> <row> + <entry><simpara>$_status</simpara></entry> <entry><simpara>_sort()</simpara></entry> <entry><simpara>_initTree()</simpara></entry> - <entry><simpara>$this->_status</simpara></entry> </row> </tbody> </tgroup> @@ -780,9 +803,17 @@ <para> Constants should always be all-uppercase, with underscores to separate words. Prefix constant names with the uppercased name - of the class/package they are used in. For example, the constants - used by the <literal>DB::</literal> package all begin with - <literal>DB_</literal>. + of the class/package they are used in. Some examples: + <informaltable> + <tgroup cols="2"> + <tbody> + <row> + <entry><simpara>DB_DATASOURCENAME</simpara></entry> + <entry><simpara>SERVICES_AMAZON_S3_LICENSEKEY</simpara></entry> + </row> + </tbody> + </tgroup> + </informaltable> <note> <simpara> The <literal>true</literal>, <literal>false</literal> and @@ -792,15 +823,6 @@ </note> </para> </sect2> - <sect2> - <title>Global Variables</title> - <para> - If your package needs to define global variables, their name - should start with a single underscore followed by the package - name and another underscore. For example, the PEAR package uses - a global variable called $_PEAR_destructor_object_list. - </para> - </sect2> </sect1> <sect1 id="standards.file">

« previous php.pear.doc (#10645) next »