CodingStandards

 

Indenting and Whitespace

Use an indent of 2 spaces, with no tabs.

Lines should have no trailing whitespace at the end.

Files should be formatted with \n as the line ending (Unix line endings), not \r\n (Windows line endings).

Operators

All binary operators (such as +, -, !=, ==, ...) should have a space before and after the operator.

Unary operators (like ++), should'nt have space between the operator and the variable.

Control Structures

For control structures (if, while, for, ...), an example will be more significant:

if (condition1 || condition2)
{
  do_something ();
}
else if (very_long_long_condition
         && another_condition)
{
}
else
{
}
  • Always use braces,
  • Place the opened brace under the keyword,
  • Place a space between the keyword and the opened parenthesis.

Functions

Like the control structures, place a space between the function name and the parenthesis:

bar = foo (arg1, arg2);

Place the variables declaration at the begening of the block function:

public void foo ()
{
  int a, b;
  Gtk.TreeView tree_view;

  tree_view = new Gtk.TreeView ();
}

Miscellaneous

  • Always use the this keyword for method and attributes of an object,
  • Don't use the var keyword,
  • For cast, prefere use the as keyword,
  • Try to limit line to 80 characteres,
  • Limit the use of the using statement.