Home Private Messages Search
CPG Dragonfly™ CMS
 
Wiki ⇒ v9 Developer's Manual ⇒ Coding standards

Wikiv9 Developer's Manual ⇒ Coding standards  

Glossary
The Project
Install
Upgrading or Switching
Dragonfly admininistration
Dragonfly public view
Dragonfly Themes
Build local server
Tips and Tricks
Rules & Regulations
v9 Developer's Manual
v10 Developer's manual
Wiki Permissions
13.2: Coding standards Parent

As you all know many people use their own standards when they develop code. Some use spaces others use tabs, some place many "1 liners" others strike it over several lines.
We will provide the rules including examples and why we do it.

Table of content

Spacing use tabs

We use tabs instead of spaces for a visual view of the 'depth' of the created code.
<?php
first level
{
    
second level {
        
3rd level {
        
}
    
}
}
The reason is simple. Some coders like a spacing of 2, others 4 and common is 8 spaces. By using tabs the designer can easily make the code viewable to his preferences since many editors have a 'tab spacing' option to set this up. A small nice benefit is that it makes the code smaller (8 spaces = 8 bytes, 1 tab = 1 byte)

1-liners

We allow them in a few ways to easy-up the code in certain non-complex circumstances. For example "$a ? $a : $b" to replace "if ... else ...".
<?php
$c
= isset($_POST['foo']) ? $_POST['foo'] : $_GET['foo'];

vs

<?php
if (isset($_POST['foo'])) {
    
$c = $_POST['foo'];
} else {
    
$c = $_GET['foo'];
}

As you can see "} else {" is also a 1-liner since many people split this up on single lines as well.
We mostly use this one as well unless the code becomes hard to read and then we use the following (mostly in "do ... while" and "switch")

<?php
if (isset($_POST['foo']))
{
    
$c = $_POST['foo'];
}
else
{
    
$c = $_GET['foo'];
}

Versioning

We use the common version standard, but slightly modified in some more detail as described in the Versioning System document.
Secondly we urge you as theme/module/add-on developers to use the same version scheme to provide you a more powerful integration through Dragonfly. Some of these integrations are "update recognition" and "theme upgrading (since 9.1.x)".

 
Updated: Wednesday, April 18, 2012 (06:20:51) by NanoCaiordo
Created:  Tuesday, November 29, 2005 (02:44:47) by DJMaze

You are seeing squares or questionmarks on this page?

All content of this website is copyrighted by the Creative Commons NC-SA
The logos and trademarks used on this site are the property of their respective owners
We are not responsible for comments posted by our users, as they are the property of the poster.
Our server runs on a P3 1.2GHz with 512MB RAM with no accelerators
Support GoPHP5.org
Interactive software released under GNU GPL, Code Credits, Privacy Policy