GnuERP Programming Guide

Eko Bono <ekobono@yahoo.de> dan Tedi Heriyanto <tedi_h@gmx.net>

v.0.0.3 : 21 May 2001

Abstract:

This guide is intended to be used by whoever involved in the GnuERP project especially the developers. The aim of this guide is to stardardize the source code produced by GnuERP project, so they can be maintained by other developers with ease, if the current developers leave or got better jobs. :)

Introduction

This programming guide is written to be used by software developers involved in GnuERP project to help them write software that is easy to maintain and read by others or by the programmers themselves.

Naming Convention

Variable

For example if your variabel is used for counting saving account, the appropriate name shoud be saving, not xxx. :)
e.g : total_saving = 0;

Constant

If you want to name a constant please name it with all capital.

e.g:

define(``PI'', 3.14);

Function

Indenting

Please use four spaces for indenting.

Files

Files Naming Convention

Please name the file with something which best describe the content of the file. So if you have a file with content describe an Account Payable, the appropriate name would be acc_payable.php, not xxx.php

Files Organization

The following is a simple diagram to describe an ideal files organization :

An example would clarify things :)

I have a project called bejo, here is the directory structure :

bejo/

bejo/class

bejo/hidden

bejo/img

bejo/includes

bejo/language

bejo/object

bejo/sql

bejo/style
the source files located in bejo/

Include Files Naming Convention

Functions that are used often should be saved in an include file, which has the following form :

<name>.inc.php

Include Files Organization

Include files should be put in a directory called includes.

Include Files Invocation

Include file should be invoked by other file with the following statement :

include(``includes/filename.php'');

Comments

One Line

A one-liner comment should begin with //.

Block

A block comment should begin with // too. Here is an example :

// function to add

// use : add(a,b,c)

Class

Class Naming Convention

Every class name should begin with a capital letter. e.g :

class MySQL

{
var $host;

var $port;

var $user;

var $passwd;

...
}

Class File Naming Convention

Class declarations and functions are saved in a file with the following structure

classname.class.php
So for the class above, the appropriate class filename would be mysql.class.php

Class File Organization

All class files should be saved in a separate directory under the name class.

Bibliography

1
Keith Gabryelski, Wildfire C++ Programming Style, 1997. http://www.cs.umd.edu/users/cml/cstyle/Wildfire-C++Style.html



Tedi Heriyanto 2001-05-21