Log in | Back to darenet.org

Development Team/Coding Standards

The following are a set of standards that should be adhered to when writing patches for ircd-darenet and services-darenet. Since these programs are based on the works of other's (outside of the DareNET development team), not all code will follow them. This, of course, will be rectified with time.

In This Guide:

Comments

Comment your code when you do something that someone else may think is not trivial.

Multiple Line

Multiple line comments should follow the C-style comment, for example: <source lang="c" line start=1 > /**

* This is a multiple line comment.
* - SecretAgent
*/</source>

Single Line

Single line comments should also be in the C style, for example: <source lang="c" line start=1 > /* This is a one-line comment. - SecretAgent */</source>

Indentation

Tabs. Tabs. ONLY TABS.

Use a single tab for each level of indentation, for example: <source lang="c" line start=1 > int main() {

 if (condition)
 {
   code
 }

}</source>

Separation

Always put a space in between a keyword like if/while and the condition, for example:

<source lang="c" line start=1 >if (foo == bar)</source>

NOT

<source lang="c" line start=1 >if(foo == bar)</source>

Braces

Always put braces opening and closing blocks on separate lines, see the indentation example.

For example, place braces like this: <source lang="c" line start=1 > if (apples == "green") {

 cout << "Apples are green" << endl;

}</source>

and NOT: <source lang="c" line start=1 > if (apples == "green") {

 cout << "Apples are green" << endl;

}</source>

The one exception to this is if you are declaring a class method which is only one line long, in that case the following is acceptable in most cases: <source lang="c" line start=1 > class foo : public bar {

 foo() { }
 getrandomfoo() { return rand(); }

};</source>