Coding Style - mikrotvison/Sidannarverkefni GitHub Wiki

Class names and function names

Use upper case letters as word separators, lower case for the rest of a word

First character in a name is upper case

No underbars ('_')

  • Example
    ThisIsMyClass();
    ThisIsMyFunction();

Variable names

Use upper case letters as word separators, lower case for the rest of the word

First character in a name is lower case

No underbars ('_')

  • Example
    thisIsMyVariable

Constant names

All uppercase

  • Example
    public static final int SIZE = 3;

Spaces

Spaces around operators

  • Example
    x = i + 1;

No spaces at in the beginning and end of parantheses

  • Example
    Do: (i + 1)
    Don't: ( i + 1 )

Spaces before and after brackets and parantheses

  • Example
    Do: x = 2 * (y + 1) - 3;
    Don't: x = 2 *(y+1)-3;

Loops

Put space before the loops parantheses

Put brace associated with a control statement on the next line

Indented to the same level as the control statement

Statements within the braces are indented to the next level.

Newline is after each loop

  • Example
    while (x == y)
    {
    Something();
    SomethingElse();
    }

SomethingOutsideTheloop();

else and else if is written on the next line

  • Example
    if (x != 2)
    {
    Something();
    }
    else
    {
    SomethingElse();
    }
⚠️ **GitHub.com Fallback** ⚠️