Coding Standard

From Toysoldiers

Revision as of 17:41, 14 September 2007 by Admin (Talk | contribs)
(diff) ←Older revision | view current revision (diff) | Newer revision→ (diff)

For the sake of consistency and easier to understand code, we will base our coding standard on the GNU Coding Standard.


Contents

[edit] Names

A name should convey in fewer than 14 characters the intent, use and type of the object. It must be descriptive, technically correct, idiomatic, appropriate - not abbreviated to the point of no return, not ambiguous and yet not longer than 14 characters long, nor should it contain expletives, colloquialisms or "silly" words like "shribblywoo". Favour clarity over brevity, and name things from the point of view of a complete idiot who had never seen code before.

[edit] Variables

[edit] Functions

[edit] Types

[edit] C++ Namespaces and Java packages

[edit] Macros

[edit] Source Files

[edit] Self-Documenting Code

[edit] Simplicity

[edit] Meaningful Names

[edit] Atomic Functions

[edit] Descriptive Types

[edit] Name Constants

[edit] Emphasise Important Code

[edit] Group Related Information

[edit] Provide a File Header

[edit] Handle Errors Appropriately

[edit] Write Meaningful Comments

[edit] Literate Programming

[edit] Documentation Tools

[edit] Consistency

[edit] Fixed tab lengths

[edit] Braces

Please use an indented brace style. For example:

int exdent()
   { 
   int a = 0, b = 0;
   while (a 1= 10)
        {  
        b++;
        a++;
        }
   return b;
   }

[edit] Language Usage


The above tips are taken from Pete Goodliffe's "Code Craft: The Practice of Writing Excellent Code".

Personal tools