Version 1 (modified by bdubbs, 11 years ago) (diff) |
---|
UltraScan III Programming Standards
Note: The purpose of these standards is to provide a consistent, professional look for the source code. Deviations from the general rules below are acceptable if they enhance the readability of the code.
- Tabs characters. There should be no embedded tab characters in the source code.
- Indentation. Normal indentation should be 2 spaces.
- Braces should generally be on a line by themselves. Example:
for ( i = 1; i = 10; i++ ) { if ( test } { block of code } }
- Braces are not required for simple if statements or loops.
if ( test ) return;
- Variable declarations.
- Each variable declaration should be in a separate line.
- Pointers and references should be associated with the type, not the variable name. That is, use the Strostrup and not the K&R style.
- If reasonable, line up variable names and any equal signs for assignments.
- Group variable definitions of the same type together.
int x; int range; QLabel* lbl_a; double temperature = 72.0; double y = 1.2;
- Class variables. Try to minimize these. When necessary, make public only when truly needed.
- Spacing.
- There should not be a space between a function name and the first argument.
- There should be a space after a programming construct
- There should be a space after an opening parenthesis or bracket and before a closing parenthesis or bracket.
- There should be a space around operators such as !, =, <=, etc.
for ( i = 0; i < 10; i++ ) { x[ i ] = function( a, b, c ); }
- Try to keep line lengths to 80 characters or less. Occasionally exceeding 80 characters is OK if a line break would detract from the overall readability.
- If arguments to a function don't fit nicely on one line, split it like this:
int lots_of_args( int an_integer, long a_long, short a_short, double a_double, float a_float ) { connect( reply, SIGNAL( error ( QNetworkReply::NetworkError ) ), this, SLOT ( postError( QNetworkReply::NetworkError ) ) ); }
- Line things up when it makes sense:
QString lastname = license.value( 0 ); QString firstname = license.value( 1 ); QString company = license.value( 2 ); QString address = license.value( 3 ); QString city = license.value( 4 ); QString state = license.value( 5 ); QString zip = license.value( 6 ); QString phone = license.value( 7 ); QString email = license.value( 8 ); QString platform = license.value( 9 ); QString opSys = license.value( 10 ); QString version = license.value( 11 ); QString validation = license.value( 12 ); QString expiration = license.value( 13 );
Attachments (2)
-
.emacs
(380 bytes) -
added by emre 11 years ago.
Emacs file for editing source code
- kdevelop.png (81.7 KB) - added by demeler 11 years ago.
Download all attachments as: .zip