Eko Bono <ekobono@yahoo.de> dan Tedi Heriyanto <tedi_h@gmx.net>
v.0.0.3 : 21 May 2001
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.
For example if your variabel is used for counting saving account, the appropriate name shoud be saving, not xxx. :)
e.g : total_saving = 0;
If you want to name a constant please name it with all capital.
e.g:
define(``PI'', 3.14);
Please use four spaces for indenting.
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
The following is a simple diagram to describe an ideal files organization :
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/stylethe source files located in bejo/
Functions that are used often should be saved in an include file, which has the following form :
<name>.inc.php
Include files should be put in a directory called includes.
Include file should be invoked by other file with the following statement :
include(``includes/filename.php'');
A one-liner comment should begin with //.
A block comment should begin with // too. Here is an example :
// function to add
// use : add(a,b,c)
Every class name should begin with a capital letter. e.g :
class MySQL
{
var $host;
var $port;
var $user;
var $passwd;
...
}
Class declarations and functions are saved in a file with the following structure
classname.class.phpSo for the class above, the appropriate class filename would be mysql.class.php
All class files should be saved in a separate directory under the name class.