1
edit
Changes
→Coding Style and Standards
== Coding Style and Standards ==
* No Tab Character allowed. (replace tabs with 4 spaces)
* Each object must have its own type:
* Open { in the same line
* Close } in the next line
* Start else in the next line
* 2 line break for new function
* Declare variable type only in prototyping
* Using namespace cio
* Variables rules
** start with flag p_, l_ (parameter, local)
** class variable start with _
** start with lower character
** use upper character from first letter of each word (from second word)
** remove vowel in a variable
** no more than 3 words for one variable
== Coding Style and Standards ==
* The following will serve as an example of our coding standard:
<big><syntaxhighlight lang="cpp">
#ifndef __FILENAME_H__ #define __FILENAME_H__ class example { // There will be a space after every class identifier for the definition public: int _data; // Member variables should start with an underscore int _arraySize // Use meaningful names for variables when applicable and use lower Camel Case int _width; // Every object have its own type char* _pArray; // Pointers should have * part of the type void display():}; void example::display() { // There will be a space after every function identifier for the definition } #endif ... #include <iostream>#include <cstring>using namespace std; int main() { int a= 0; // Indentation is 4 spaces int b= 1; // NO Tab characters allowed! Replace every tab character with 4 spaces.CDialog D char name[] = "Spoom"; // Put a newline after variable declaration if(a > b ? a : b) { a = a * b; // Put a space between EVERY variable and operator } // Put a newline after a control structure if(!strcmp(name, "Spoom")) { cout << "Welcome, Spoom!" << endl; // Every statement within a control structure will } // be wrapped in braces, even if there is only 1 line else { cout << "Get out." << endl; } return 0;}
</syntaxhighlight></big>