History of CodingGuidelines

Version 12


Created by: Jan Lindåker, Last modification: 07 Oct 2004 (15:06 UTC) by Jan Lindåker
  1. CodingGuidelines
    1. ClassStructure
    2. ObjectOrientation
    3. StubsAndMockObects
    4. Model View Controller - MVC
    5. TestingSuites
    6. APIDocumentation

These CodingGuidelines are enforced for code that is a part of the standard bitweaver distribution. If you start your own package, you are welcome to choose whatever standards you like. However, if you play in core sandbox, we need to keep things need and tidy. We have a good bit legacy code that does not follow our own conventions, however, we are fixing as fast as we can with the ArchitectureTransition.

File Types and Naming Conventions

(:arrow:) All files have underscores between every word and there are no hypens allowed.

There are several type of files, and each should be name as follow
  • Presentation files, such as "wiki/list_pages.php", should be named with an underscore seperateing each word. i.e. list_pages.php, and all lower case. There should be no reference to "tiki" in the file name, and it is best to keep the names short, and not redundant with the package they are in. For example "articles/edit_article.php" should be simple "articles/edit.php"
  • Included files if your file is only included by other files and never invoked directly, it should follow the same rules athe presentation files, however, it should have _inc.php at the end, such as "wiki/page_setup_inc.php"
  • Class files shoud be named identically to the name of the class they contain, i.e. "TikiSystem.php". There should be NO CODE outside of the class definition, and nothing should be declared. Sometimes, it is practical to put global function definitions in the class files, and that is acceptable. Classes should be declared in a presentation or include file.
  • Library files are nothing but a big pile of preocedural function definitions and have "_lib.php" at the end, such as "util/zip_lib.php"
  • Template files are for smarty, and they should follow convetion for presentation files, such as "wiki/templates/show_page.tpl"
There are a few special file names that the KernelPackage will look for in each Package. Below is an example for a fictional package named "somepackage":
  1. somepackage/tiki_setup_inc.php is automatically parsed by the KernelPackage at setup time (technically by TikiSystem::scanPackages()
  2. somepackage/templates/admin_somepackage.tpl and somepackage/admin/admin_somepackage_inc.php are automatically assumed, and will be included if you link to www.yoursite.com/kernel/admin/index.php?page=somepackage

Coding Conventions

  • Sometimes we need to hack something together with the intention of fixing it later. Such code should be commented with a comment starting with "@todo" and explaining what needs to be done and why it wasn't done right. Using "@todo" will make the text turn up in the source documentation if doxygen is configured to show it.
  • all variables that are declared global must be in the format $gVariableName
  • all function parameters should be prefixed with $p, like: function foo( $pBar )
  • all define(CONSTANT) that you consider configurable by the user should have an if( defined(CONSTANT) ) check beforehand.
  • Please follow traditional unix brace policy. Paren styles vary, and are up to individual preference:
function foo( $pBar ) {
if( condition ) {

Config Files

  • ))config_inc.php(( is for the users custom settings that override settings declared later on in the process. This should only be included directly by config_defaults_inc.php and during the install.
  • ))config_defaults_inc.php(( checks and includes config_inc.php if it exists. All defaults should be defined in this file, not in the code. config_default_inc.php should only be called from setup_inc.php. Only setting of variables and logic in setting of variables should be in this file.
  • setup_inc.php defines constants and sets up the environment for bitweaver. It includes the file config_defaults_inc.php which inturn includes config_inc.php. Once these files are included, logic and insanity checks are performed along with setting up of constants, etc. If a user wishes to over-ride anything by including it in config_inc.php, the code here must not complain (ie if(!defined(SOME_CONST)) { define('SOME_CONST'...etc) unless a sanity check has failed.

Page History
17 Mar 2009 (21:16 UTC)
package icon
Daniel Sutcliffe71.161.102.626
Current • Source
Daniel Sutcliffe71.161.102.624
View • Compare • Difference • Source
Daniel Sutcliffe71.161.102.623
View • Compare • Difference • Source
View • Compare • Difference • Source
View • Compare • Difference • Source
View • Compare • Difference • Source
Jerry Russell66.25.205.23218
View • Compare • Difference • Source
View • Compare • Difference • Source
View • Compare • Difference • Source
View • Compare • Difference • Source
View • Compare • Difference • Source
Jan Lindåker192.16.134.6612
View • Compare • Difference • Source
View • Compare • Difference • Source
Stephan Borg218.214.1.11310
View • Compare • Difference • Source
Stephan Borg218.214.1.1139
View • Compare • Difference • Source
View • Compare • Difference • Source