Coding Rules

  • Use Visual Studio 2010 default settings or similar settings in another editor.
  • Indents are 4 spaces. You can use Productivity Power Tools for VS to convert tab characters into spaces.
  • Fields should be declared private and above all methods.
  • Put curly brackets on a new line and close it in the same indentation.
  • Keep classes small up to maximum 500 lines
  • Keep methods small up to maximum 35 lines
  • Use usings as much as possible and remove unused usings
  • When using an if condition with one statement, put the statement on the next line.
    if (true)
        DoSomething();
  • When using an if condition with one statement after if condition and else condition, curly brackets are optional.
    if (true)
        DoSomething();
    else
        DoSomethingElse();
  • When using an if condition with curly brackets, use curly brackets for all attached conditions
    if (true)
    {
        x++;
        DoSomething();
    }
    else
    {
        DoSomethingElse();
    }
  • Use String.Format when possible
  • Use String.Empty instead of ""
  • Use String.IsNullOrEmpty() instead of (x == null || x = "")

Last edited Aug 23, 2012 at 8:57 PM by ondrejvrsan, version 7

Comments

No comments yet.