Batoi RAD Framework Coding Standards and Conventions


The Batoi RAD Framework reinforces the correct development paradigm through the Batoi RAD Framework IDE and a set of prescribed guidelines for development. Coding standards and conventions do help in this direction. Please find the following list of guidelines as recommendations from us, but you are free to choose your style.

Server-side Development with PHP

  1. Keep one class one file decorum so that we can use php-doc for technical documentation. For more details about PHPDoc, please refer to the official documentation.
  2. Always use to delimit PHP code, not the shorthand. You can install the Batoi RAD Framework and can start testing the first instance of your application in a matter of minutes. Moreover, the Batoi RAD Framework offers an easy learning curve for a web developer new to it.
  3. Use an indent of 4 spaces, with no tabs.
  4. Control statements should have one space between the control keyword and opening parenthesis, to distinguish them from function calls.
  5. Functions should be called with no spaces between the function name, the opening parenthesis, and the first parameter; spaces between commas and each parameter, and no space between the last parameter, the closing parenthesis, and the semicolon. There should be one space on either side of an equal sign used to assign the return value of a function to a variable.
  6. Function declarations follow the "one true brace" convention. Arguments with default values go at the end of the argument list. Always attempt to return a meaningful value from a function if one is appropriate.
  7. Inline documentation for classes should follow the PHPDoc convention, similar to Javadoc.
  8. Non-documentation comments are strongly encouraged. A general rule of thumb is that if you look at a section of code and think "Wow, I don't want to try and describe that", you need to comment it before you forget how it works.
  9. C style comments (/* */) and standard C++ comments (//) are both fine. No Perl/shell style comments (#) should be used. Comments may be added at the start of the program file, before starting functions, or classes or variables, block of code.
  10. Use example.com, example.org and example.net for all example URLs and email addresses, as per RFC 2606.
  11. Identifier names should be explanatory, and should be in word-case. Also the first letter of the variable or parameter or IDs must tell the nature thereof. Examples (please note carefully) are:
    • Class: ClassName
    • Object: oObjectName
    • Function or method Name: functionName()
    • Constants: CONSTANTNAME
    • String Variable: $sVariableName
    • Array Variable: $aVariableName
    • Integer Variable: $iVariableName
    • Float Variable: $fVariableName
    • Boolean Variable: $bVariableName

Client-side Development with HTML and CSS

  1. Style-sheet must be used for all properties of the HTML elements.
  2. HTML code must be XHTML1.0 strict: https://validator.w3.org/
  3. CSS code must comply with CSS2 standard: https://jigsaw.w3.org/css-validator/
  4. C style comments (/* */) and standard C++ comments (//) are both fine.
  5. ID or NAME attributes should be explanatory, and should be in word-case. Examples (please note carefully) are:
    • CSS Style Class: ClassName
    • HTML ID Attribute: attributeName
    • Form ID: formId
    • Text Box Name/ID: txtFieldName
    • Text Area Name/ID: taFieldName
    • Drop Menu Name/ID: dmFieldName
    • Radio Button Name/ID: rbFieldName
    • Checkbox Name/ID: chkFieldName
    • Button Name/ID: btnFieldName
    • Hidden Field Name: hidFieldName

Client-side Development with JavaScript

  1. C style comments (/* */) and standard C++ comments (//) are both fine.
  2. Identifier names should be explanatory, and should be in word-case. Also the first letter of the variable or parameter or IDs must tell the nature thereof. Examples (please note carefully) are:
    • Object: oObjectName
    • Method Name: functionName()
    • String Variable: sVariableName
    • Array Variable: aVariableName
    • Integer Variable: iVariableName
    • Float Variable: fVariableName
    • Boolean Variable: bVariableName