Coding Conventions
From WinBolo
Contents |
Comments
Method Header Comments
This should go above every method, both it's implementation (in .c files) and definition (in .h files).
/********************************************************* *NAME: <functionName> *AUTHOR: <functionAuthor> *CREATION DATE: <DD/MM/YY> *LAST MODIFIED: <DD/MM/YY> *PURPOSE: * Short description of function goes here * *ARGUMENTS: * firstParameter - Short explanation of what this parameter is * secondParameter - Short explanation of what this parameter is *********************************************************/
File Header Comments
Single Line Comments
As this code is trying to be 100% ANSI C compliant, you [b]must[/b] use a forward slash immediately followed by an asterisk to start the comment and then an asterisk and forward slash to close the comment.
/* This is a comment and will be ignored by the compiler */
Multiline Comments
Variable Cases
Indentions
Conditionals
Conditionals should follow the below syntax of having the openning curly brace on the same line as the conditional. The only brace that is on it's own line should one that ends the conditional.
if (srtDelay = 0) { srtDelay = 1; } else if (srtDelay = 1) { strDelay = 0; } else { srtDelay = -1 }
Switch statements should follow the syntax below.
switch (value) { case BsTrees: dest.left += (zoomFactor * BS_DOT_TREE_OFFSET_X); dest.top += (zoomFactor * BS_DOT_TREE_OFFSET_Y); break; case BsRoad: dest.left += (zoomFactor * BS_DOT_ROAD_OFFSET_X); dest.top += (zoomFactor * BS_DOT_ROAD_OFFSET_Y); break; case BsBuilding: dest.left += (zoomFactor * BS_DOT_BUILDING_OFFSET_X); dest.top += (zoomFactor * BS_DOT_BUILDING_OFFSET_Y); break; case BsPillbox: dest.left += (zoomFactor * BS_DOT_PILLBOX_OFFSET_X); dest.top+= (zoomFactor * BS_DOT_PILLBOX_OFFSET_Y); break; default: /* BsMine:*/ dest.left += (zoomFactor * BS_DOT_MINE_OFFSET_X); dest.top += (zoomFactor * BS_DOT_MINE_OFFSET_Y); break; }