Coding style

This page tries to describe some of the conventions we try to adhere to for our code.

Class layout


class Something
{
    private bool prop1;
    protected bool prop2;
 
    public bool Prop1
    {
        get { return prop1; }
        set { prop1 = value; }
    }
 
    public bool Prop2
    {
        get { return prop2; }
        set { prop2 = value; }
    }
 
    public Something()
    {
    }
 
    public void Do()
    {
    }
 
    protected void Do2()
    {
    }
 
    private void Do3()
    {
    }
}

So, the ordering of class-elements is like this:
  • Private variables (note we explicitly declare them private for clearness)
  • Protected variables
  • Properties
  • Constructors
  • Public functions
  • Protected functions
  • Private functions

Commenting

At least all public functions, variables and properties and all classes and their constructors should be commented. But adding comments to private variables and functions is also encouraged.

Last edited Dec 24, 2008 at 11:18 AM by Gloei, version 2

Comments

No comments yet.