General guidelines

  • Use [TAB] for create indents.

  • Use the "Allman style" for braces. You can skip braces for one-line returns (unless the condition requires a second line).

  • Use multiple early return statements when possible to prevent functions from becoming over-indented.

  • Specify each variable's type. Don't use the var keyword.

  • Use a single empty line to separate parts of code.

void Foo()
{
    // Short check
    bool isValid = CheckValidity();
    if (!isValid)
        return;
        
    // Longer checks
    if (!longerValidCheckA &&
        longerValidCheckB)
    {
        return;
    }
    
    DoSomething();
}

Last updated