Changes

Jump to: navigation, search

The Scurvy Curs

2,060 bytes added, 13:13, 7 November 2012
Coding Rules
== Coding Rules ==
 
All of our code '''must''' follow the following standards.
 
==== Conventions ====
 
* Always always ''always'' simplify code so it is easily readable! E.G.
<pre>
c += !!(valid); // NOT THIS
 
if (valid) { // INSTEAD THIS
c++;
}
</pre>
 
* If confusing code cannot be avoided, ''comment it''! E.G.
 
<pre>
c += !!(validNames); // If [validNames] is true (greater than 0), [c] is increased by one.
</pre>
 
==== Format ====
* All indents must be composed of two space characters E.G.
<pre>
Where . = space
 
First code level
..Second code level
....Third Code level
..Second code level
....Third Code level
......Fourth Code level
....Third code level
..Second code level
First code level
</pre>
 
* All variables must be declared on separate lines E.G.
 
<pre>
int i, j, k; // NOT THIS
 
int i; // INSTEAD THIS
int j;
int k;
</pre>
 
* Code blocks are formatted like the following:
 
<pre>
if (condition) {
// THIS
}
 
vs
 
if (condition)
{
// NOT THIS
}
</pre>
 
* Conditions for logic statements (if, while etc.) must be spaced like the following:
 
<pre>
if (a > b) // Brackets wrap a simple condition
 
OR
 
if ( (strlen(blah) - 1) > methodA(b) ) // If statement brackets are 1 space away from conditions
</pre>
 
* ELSE statements must be spaced like the following:
 
<pre>
 
if (condition) {
// Code here
} < -------- THIS!
else {
// Code here
}
 
VS
 
if (condition) {
// Code here
} else { <------------ NOT THIS!
// Code here
}
</pre>
 
==== Comments ====
* Before a method/function E.G.
 
<pre>
/**************
* methodName *
**********************************
* Concise description of purpose *
**********************************/
void methodName ( type paramName ) {
// CODE HERE
}
</pre>
 
* Before and after blocks of logic E.G.
 
<pre>
main() {
// Begin (CODE BLOCK PURPOSE HERE)
CODE HERE
// End (CODE BLOCK PURPOSE HERE - Optional, depending on length of code block)
}
</pre>
 
* After lengthy logic constructs (if, while, for etc.) E.G.
 
<pre>
if (condition) {
 
// many lines of code
 
} // End-if < -------- THIS PART
</pre>
 
== meetings ==
* latest will be on top

Navigation menu