Developer guideline » History » Revision 4
« Previous |
Revision 4/17
(diff)
| Next »
Max Milbers, 04/17/2010 01:42 PM
Developer guideline¶
Code Formatting:¶
We follow the joomla standard in most cases. We use camelCase for methods. For faster copypasting and working with database fields. Both variable and database fields are lowercase and seperated with "_". You may use for internal variables camelCase also.
Example:
@Example:
function exampleMethod($data = 0) {
if (!$product_id) $product_id = JRequest::getInt('product_id', 0);
if ($product_id > 0) {
...;
}
}
SQL Formatting:¶
The queries should follow this format:
$q = 'SELECT `example_id` FROM `#__vm_table` WHERE `user_id`=' . (int)$user_id;
or if the
$user_id is an array, use $user_id["myId"]
Placing of the ` improves speed, because the sql-engine can parse faster ( and do not have to reparse).
Variable Formatting:¶
Due abstract logic many people name their variables or database fields just "id", "key", "value" and so on.
In our case we want to rewrite the structure of an old code, therefore it is very important to find the variable in the code rather fields in the database.
So we want a kind of this: <classname><tablename>variable like here
$vendor_id or $payment_method_id
Exception from this rule is the use of ordering and published. Ordering and published with 0 and 1 as values are useable with the joomla standard methods.
Filename Formatting:¶
Filenames should be lowercase.
Models filenames (mymodel.php), view direcorynames (myview), all helper files and probably all other files loaded by the Joomla Framework, must be lowercase, no matter how you load the file:
$this->loadHelper('adminMenu'); // looks for the file helpers/adminmenu.php
More complex filenames that are specific to your task and loaded by your own code (using require_once()), e.g. mySpecificClass.php, can be camelcase.
Read this article for more info http://docs.joomla.org/Talk:Developing_a_Model-View-Controller_Component_-_Part_1#Use_lowercase_file_and_folder_names_in_your_components.21
Character Encoding:¶
Like in joomla we use UTF-8. Please ensure the right character set in your IDE.
Updated by Max Milbers over 14 years ago · 4 revisions