Development Guidelines (old)

From Cloudrexx Development Wiki
Jump to: navigation, search

The development guidelines are currently being revised, the currently approved draft can be found here


Coding Standards

Contrexx should be developed according to the Pear Coding Standards.


Relative and absolute paths

You must always use relative paths for content stuff such as images and JavaScrirt- or StyleSheet inclusions. <highlightsyntax>// right $output = '<img src="'.ASCMS_PATH_OFFSET.'images/modules/access/edit.gif">';

// wrong $output = '<img src="/images/modules/access/edit.gif">';</highlightsyntax>

You must always use absolute paths for script or file inclusions in the PHP code due to security restrictions that could be set. <highlightsyntax>// right require_once ASCMS_CORE_MODULE_PATH.'/access/lib/AccessLib.class.php';

// wrong require_once 'lib/AccessLib.class.php';</highlightsyntax>

String Handling

See separate article Security (Contrexx Input / Output Handling)


Contrexx uses the ADOdb database abstraction layer.

SQL Statements

  • You must use the constant DBPREFIX as a table prefix in all of your queries.

<highlightsyntax>$objDatabase->Execute('SELECT 1 FROM `'.DBPREFIX.'access_users`');</highlightsyntax>

  • Never select all columns of a table using the asterisk wildcard. Instead list explicit every column that you need to select (also if you need all columns of a table to be returned). Using an asterisk slows down the database needlessly, because it first has to look up what columns are present.
  • Use INNER JOINS where applicable.
    MySQL does "only" know INNER or OUTER joins. In the context of MySQL, when someone talks about simple joins, he usually refers to INNER joins.
    The keyword JOIN in MySQL is equivalent as to use LEFT OUTER JOIN, which is less efficient.
    An INNER JOIN builds a 1-1 relation of data-sets. Whereas an OUTER JOIN builds a 1-n (for left joins and n-1 for right joins) relation of data-sets. For this reason, a INNER JOIN is always more efficient if you are looking exclusively for 1-1 relation of data-sets.
    So in MySQL the expression JOIN is an equivalent to LEFT OUTER JOIN and not, as one would assume, a simple, INNER JOIN.

Templates and HTML-Output

All HTML output must be XHTML1.0 Transitional validated. There are many browser extensions available that provide an in browser HTML validator. E.g. HTML Validator for Firefox and Mozilla.

Browser Compatibility

The Front- and Backend layout must be compatible with Firefox, Internet Explorer 6/7/8 and Safari. Due that it is not possible to have installed several versions of IE installed at the same time on a Windows host, Microsoft provides several Virtual PC images for every of these versions.


See article Security