My favorites | Sign in
Project Logo
                
Search
for
Updated Aug 02, 2007 by uhuraproject
Labels: Phase-Requirements
CodingStyle  

You'll find the coding style/conventions for Uhura here.

Introduction

This project doesn't really use any popular style like K&R, GNU or Java conventions. The following code section is to demonstrate the style, and not to be proper code.

Details

Indentation

Use spaces, 4 character wide, not tabs.

void foo() {
    Console.WriteLine("Uhura");
}

Vertical Alignment

Use vertical alignment for similar or related elements

int   i[5] = {    1,   2,   3,   4,   5 };
char  c[3] = {  'a', 'b', 'c' };
float f[2] = { 1.5f,  .2 };

Spacing

Use spaces to for arithmetic, separation and controls.

void Counter(int count) {
    for (count = 0; count < 10; count++)
        count = count * count + count;
}

Naming

Use of Microsoft Naming Guidelines for a consistent style.

No Lefthand Comparison

In a comparison place constant on the right side.

if (condition == false) { /* ... */ }

Control Structures

Curly brackets are placed after control flow construct

switch (level) {
case One:
    start_level(1);
    break;
case Two:
    start_level(2);
    break;
}

Lists

Lists items will be placed in separate lines, if they get to long.

int foobar(int very_important_int,
           int another_very_important_int,
           double now_a_double);

Comments

Use commands to clarify code, but not how it works. Use C++ style comments for short one line comments, and C style comments for multiline

// single line comment

/*
 * multi line comment
 */

Length of Line

Try to keep the line 80 chars short. If it helps for readability break the line, otherwise use a long line.


Sign in to add a comment
Hosted by Google Code