-
don't initialize variables on the same line as their declaration,
unless it's an array of strings or something.
// yes:
int i;
i = 7;
//no:
int i = 7;
// okay by virtue of real convenience:
char* s[] = {"now", "this is", "convenience!!"};
-
open and close braces always go on their own line.
if (yadda)
{
yo();
}
-
open and close braces are indented to line up with the left edge of the code they contain.
if (yadda)
{
yo();
}
-
When naming variables and functions, use frequently-repeated words earlier so that things line up and it's easy to read.
// yes:
int RenderInit ();
void RenderGo ();
unsigned char* RenderUpdate ();
int RenderDeinit ();
// no:
int InitRender ();
void GoRender ();
unsigned char* UpdateRender ();
int DeInitRender ();
-
Line up everything possible!
// bad:
int RenderInit();
void RenderGo();
unsigned char* RenderUpdate();
int RenderDeinit();
// better:
int RenderInit();
void RenderGo();
unsigned char* RenderUpdate();
int RenderDeinit();
// best:
int RenderInit ();
void RenderGo ();
unsigned char* RenderUpdate ();
int RenderDeinit ();
-
Use proper spelling.
Especially function names & member variables which
will be used by other programmers.