Changes between Initial Version and Version 1 of Cross/CodingGuidelines

Show
Ignore:
Timestamp:
09/10/09 15:35:53 (15 years ago)
Author:
bhilburn
Comment:

Creating a basic page about VTCROSS coding style.

Legend:

Unmodified
Added
Removed
Modified
  • Cross/CodingGuidelines

    v1 v1  
     1= VTCROSS Coding Guidelines = 
     2 
     3== General Principles == 
     4 
     5When editing a file, try to follow the coding style that already exists in that file.  Inconsistent style makes code hard to read and disorganized.  Code should stress readability over conciseness. 
     6 
     7== Programming Model == 
     8 
     9We have worked very hard to develop VTCROSS as a modular, object-oriented, software platform.  Please help us keep it that way!  Do not re-implement classes and libraries when you can simply inherit from the ones already available and add functionality!  We want to keep VTCROSS as easy to extend as possible, while minimizing code redundancy. 
     10 
     11For more information on Object-Oriented Programming, see [http://en.wikipedia.org/wiki/Object-oriented_programming OOP] 
     12 
     13== Tabs and Spaces == 
     14 
     15All tabs should be 4 characters long, and should be replaced by spaces.  Most modern editors have an option to replace tabs with spaces - make sure this is on at all times while editing VTCROSS code! 
     16 
     17Note that this doesn't apply to tab-delimited languages, like 'Make'. 
     18 
     19== File Widths == 
     20 
     21Please limit files to 80 columns in length.  If a line needs to be wrapped to the following line, please use '\' to delimit the break. 
     22 
     23== Variable Names == 
     24 
     25Variable names should be one string, lower-camel-cased: e.g. lowerCamelCased.  Avoid using single-character variable names like 'c' for 'count'.  Also, full words are preferred over concatenated versions - i.e. don't use 'shrt' over 'short'.  Common abbreviations like 'num' and 'ptr' are acceptable. 
     26 
     27== Variable Typing == 
     28 
     29Only specified-width data typing should be used.  These are defined by an IEEE standard, found here [http://www.opengroup.org/onlinepubs/9699919799/basedefs/stdint.h.html stdint.h] 
     30 
     31To use these types, include <stdint.h> in your code.  Examples of use: 
     32 * Instead of 'int', use 'int32_t' 
     33 * Instead of 'unsigned short', use 'uint16_t' 
     34 
     35In addition, use the keyword 'NULL' over simply using '0' when using the NULL memory address. 
     36 
     37== Function and Class Declarations == 
     38 
     39Function and Class names should be one string, upper-camel-cased: e.g. UpperCamelCased.  Again, follow the guidelines for variable names regarding shortened forms of words. 
     40 
     41Function return types should be on the line above the function name.  Parameter lists should wrap before the 80th column: 
     42{{{ 
     43#!cpp 
     44int32_t 
     45SomeClass::SomeFunction(int32_t argumentOne, int32_t argumentTwo, char argumentThree \ 
     46        char argumentFour) { 
     47    .... 
     48} 
     49}}} 
     50 
     51== Parenthesis and Argument Lists == 
     52 
     53There should be no space between opening/closing parenthesis and text.  For example, do NOT do this: 
     54{{{ 
     55#!cpp 
     56if ( conditional ) { 
     57   .... 
     58} 
     59}}} 
     60 
     61Instead, VTCROSS style looks like this: 
     62{{{ 
     63#!cpp 
     64if(conditional) { 
     65   .... 
     66} 
     67}}} 
     68 
     69== Brackets == 
     70 
     71When defining functions or classes, brackets go on separate lines from the declaration: 
     72{{{ 
     73#!cpp 
     74void SomeFunction() 
     75{ 
     76    .... 
     77} 
     78 
     79class SomeClass 
     80{ 
     81    .... 
     82}; 
     83}}} 
     84 
     85For loop structures, the opening bracket should go on the same line as the conditional, and the closing bracket should be on it's own line: 
     86{{{ 
     87#!cpp 
     88if(conditional) { 
     89    .... 
     90} 
     91 
     92if(conditional) { 
     93    .... 
     94} else if(conditional) { 
     95    .... 
     96} else { 
     97    .... 
     98} 
     99 
     100while(conditional) { 
     101    .... 
     102} 
     103 
     104do { 
     105   .... 
     106} while(conditional); 
     107 
     108for(size_t i; i < variable; i++) { 
     109    .... 
     110} 
     111}}} 
     112 
     113== Questions == 
     114 
     115If you have any questions about VTCROSS coding style or procedures, please [wiki:Cross/Contact get in touch with us]!