Revision history for CodingConventions
Additions:
|=|{{image alt="webERP logo" title="webERP Logo" url="images/webERPlogo.gif"}}|=|[[HomePage | What Is webERP]] |=| [[WeberpFeatures | webERP Features]] |=|[[WeberpFaq | Documentation]]||
Deletions:
Additions:
|=|{{image alt="webERP logo" title="webERP Logo" url="images/webERPlogo.gif"}}|=|[[HomePage | What Is webERP]] |=| [[WeberpFeatures webERP Features]] |=|[[WeberpFaq | Documentation]]||
|=|[[WeberpSupport | Support]] |=|[[http://www.weberp.org/forum Forum]] |=|{{image class="center" alt="Sourceforge Logo" title="Sourceforge Logo" url="http://sflogo.sourceforge.net/sflogo.php?group_id=70949&type=9" link="http://sourceforge.net/projects/web-erp"}} |=| [[http://sourceforge.net/project/platformdownload.php?group_id=70949&sel_platform=3757 Download]] |=| [[http://www.weberp.org/weberp/index.php Demo]] |=|[[WeberpDevelopment | Development]]||
|=|[[WeberpSupport | Support]] |=|[[http://www.weberp.org/forum Forum]] |=|{{image class="center" alt="Sourceforge Logo" title="Sourceforge Logo" url="http://sflogo.sourceforge.net/sflogo.php?group_id=70949&type=9" link="http://sourceforge.net/projects/web-erp"}} |=| [[http://sourceforge.net/project/platformdownload.php?group_id=70949&sel_platform=3757 Download]] |=| [[http://www.weberp.org/weberp/index.php Demo]] |=|[[WeberpDevelopment | Development]]||
Deletions:
|=|[[WeberpSupport Support]] |=|[[http://www.weberp.org/forum Forum]] |=|{{image class="center" alt="Sourceforge Logo" title="Sourceforge Logo" url="http://sflogo.sourceforge.net/sflogo.php?group_id=70949&type=9" link="http://sourceforge.net/projects/web-erp"}} |=| [[http://sourceforge.net/project/platformdownload.php?group_id=70949&sel_platform=3757 Download]] |=| [[http://www.weberp.org/weberp/index.php Demo]] |=|[[WeberpDevelopment Development]]||
Additions:
if ($OneTwoThree==$_POST['OneTwoThree']
AND $myrow['onetwothree']==$_SESSION['OneTwoThree']) {
AND $myrow['onetwothree']==$_SESSION['OneTwoThree']) {
Additions:
**PHP Functions and Keywords**
Always in lower case
**With the Exception of PHP Logical Operators**
i.e. AND and OR
Always in UPPER CASE - the upper case separates the predominantely lower case comparison expressions for improved readability.
e.g.
if ($OneTwoThree==$_POST['OneTwoThree'] and $myrow['onetwothree']==$_SESSION['OneTwoThree']) {
if ($OneTwoThree==$_POST['OneTwoThree'] AND $myrow['onetwothree']==$_SESSION['OneTwoThree']) {
Where there are many comaparisons new lines should be created for each comparison
Always in lower case
**With the Exception of PHP Logical Operators**
i.e. AND and OR
Always in UPPER CASE - the upper case separates the predominantely lower case comparison expressions for improved readability.
e.g.
if ($OneTwoThree==$_POST['OneTwoThree'] and $myrow['onetwothree']==$_SESSION['OneTwoThree']) {
if ($OneTwoThree==$_POST['OneTwoThree'] AND $myrow['onetwothree']==$_SESSION['OneTwoThree']) {
Where there are many comaparisons new lines should be created for each comparison
Additions:
|=|{{image alt="webERP logo" title="webERP Logo" url="images/webERPlogo.gif"}}|=|[[HomePage What Is webERP]] |=| [[WeberpFeatures webERP Features]] |=|[[WeberpFaq Documentation]]||
|=|[[WeberpSupport Support]] |=|[[http://www.weberp.org/forum Forum]] |=|{{image class="center" alt="Sourceforge Logo" title="Sourceforge Logo" url="http://sflogo.sourceforge.net/sflogo.php?group_id=70949&type=9" link="http://sourceforge.net/projects/web-erp"}} |=| [[http://sourceforge.net/project/platformdownload.php?group_id=70949&sel_platform=3757 Download]] |=| [[http://www.weberp.org/weberp/index.php Demo]] |=|[[WeberpDevelopment Development]]||
|=|[[WeberpSupport Support]] |=|[[http://www.weberp.org/forum Forum]] |=|{{image class="center" alt="Sourceforge Logo" title="Sourceforge Logo" url="http://sflogo.sourceforge.net/sflogo.php?group_id=70949&type=9" link="http://sourceforge.net/projects/web-erp"}} |=| [[http://sourceforge.net/project/platformdownload.php?group_id=70949&sel_platform=3757 Download]] |=| [[http://www.weberp.org/weberp/index.php Demo]] |=|[[WeberpDevelopment Development]]||
Deletions:
|=|[[WeberpSupport Support]] |=| [[http://sourceforge.net/projects/web-erp Sourceforge Project Page]] |=| [[http://sourceforge.net/project/platformdownload.php?group_id=70949&sel_platform=3757 Download]] |=| [[http://www.weberp.org/weberp/index.php Demo]] |=|[[WeberpDevelopment Development]]||
Additions:
This should be avoided in favour of using $_POST['StartingCustomer'] everywhere it is required so the reader can see where the variable comes from.
echo _('Some text with a') . ' ' . $Variable;
to reduce the parsing job required of the web-server. Notice all strings need to be inside the gettext _() function.
Most programming editors have word wrap and this is preferred to manual line breaks.
All scripts should have a comment in the first few lines with the script name and revision number in it if the following comment is pasted into it the SVN repository automatically updates the revision number.
/* $Id: AccountGroups.php 4735 2011-10-29 05:59:53Z daintree $*/
echo _('Some text with a') . ' ' . $Variable;
to reduce the parsing job required of the web-server. Notice all strings need to be inside the gettext _() function.
Most programming editors have word wrap and this is preferred to manual line breaks.
All scripts should have a comment in the first few lines with the script name and revision number in it if the following comment is pasted into it the SVN repository automatically updates the revision number.
/* $Id: AccountGroups.php 4735 2011-10-29 05:59:53Z daintree $*/
Deletions:
echo 'Some text with a ' . $Variable;
to reduce the parsing job required of the web-server.
It is recommended that you break lines at approximately 75-85 characters.
All scripts should have a comment in the first few lines with the script revision number in it if the following comment is pasted into it the CVS automatically updates the revision number.
/* $Revision: 1.7 $ */
Additions:
All control structures (these include if, for, while, switch) must always use [[http://en.wikipedia.org/wiki/Indent_style#Variant:_1TBS "1 True Brace" style statement blocks]].
Deletions:
Additions:
All control structures (these include if, for, while, switch) must always use ((http://en.wikipedia.org/wiki/Indent_style#Variant:_1TBS "1 True Brace" style statement blocks)).
Deletions:
Additions:
HTML keywords and tags should be in lower case to improve xhtml compatibility.
note that there should be no trailing spaces on the string to be translated inside the _() function call
The only exception to this is that when constructing SQL statements, due to the requirement to single quote string literals in SQL statements, the entire SQL string should always be written using double quotes. (See below)
if ($VariableName == true) echo _('Variable was true');
Whenever a statement block is used code within the block should be one tab indented. Indenting code correctly is critical to avoid logic errors and to imrpove readability.
note that there should be no trailing spaces on the string to be translated inside the _() function call
The only exception to this is that when constructing SQL statements, due to the requirement to single quote string literals in SQL statements, the entire SQL string should always be written using double quotes. (See below)
if ($VariableName == true) echo _('Variable was true');
Whenever a statement block is used code within the block should be one tab indented. Indenting code correctly is critical to avoid logic errors and to imrpove readability.
Deletions:
note that there should be no trailing spaces or punctuation on the string to be translated inside the _() function call
if ($VariableName == true)
Whenever a statement block is used code within the block should be one tab indented.
Additions:
The variables $i $j and $k can be used as a counters.
Deletions:
Additions:
It is a core goal of webERP to be easy to read for business people and newcomers to PHP. This requires some compromises, but mostly much of these standards represent good programming practise and the adoption of conventions which make the code consistently easy to read throughout.
All code in webERP must conform to these standards.
**Function/Class/Variable/Field Naming**
NOTE: Since variables incorporated into an SQL string need to be quoted with single quotes inside the SQL string, the SQL strings themselves need to be quoted inside double quotes.
This is the one exception to the general rule to always use single quotes for strings (which makes the parsing job for PHP easier and quicker).
All code in webERP must conform to these standards.
**Function/Class/Variable/Field Naming**
NOTE: Since variables incorporated into an SQL string need to be quoted with single quotes inside the SQL string, the SQL strings themselves need to be quoted inside double quotes.
This is the one exception to the general rule to always use single quotes for strings (which makes the parsing job for PHP easier and quicker).
Deletions:
**Function/Class/Variable Naming**
NOTE: Since variables incorporated into an SQL string need to be quoted with single quotes, SQL strings in general need to be quoted inside double quotes. This is the one exception to the general rule to always use single quotes for strings. Where an SQL string has not variables that need to be quoted then single quotes can be used for the whole SQL string.
Additions:
It is a core goal of webERP to be easy to read for business people and newcomers to PHP. This requires some compromises, but mostly much of these standards represent good programming practise and the adoption of conventions which make the code consistent throughout.
Additions:
Quoting SQL variables - variables incorporated into SQL strings need to be inside SINGLE quotes so that the variable cannot be used by a hacker to send spurious SQL to retrieve private data.
NOTE: Since variables incorporated into an SQL string need to be quoted with single quotes, SQL strings in general need to be quoted inside double quotes. This is the one exception to the general rule to always use single quotes for strings. Where an SQL string has not variables that need to be quoted then single quotes can be used for the whole SQL string.
NOTE: Since variables incorporated into an SQL string need to be quoted with single quotes, SQL strings in general need to be quoted inside double quotes. This is the one exception to the general rule to always use single quotes for strings. Where an SQL string has not variables that need to be quoted then single quotes can be used for the whole SQL string.