wiki:CodingGuidelines

Version 4 (modified by shane, 10 years ago) (diff)

Add link to Python style guildline

This page documents some coding guidelines.

Python Style

For Python coding, we will use the Python style guidelines:

http://www.python.org/dev/peps/pep-0008/

C++ Style

You can also see the BIND 9 coding guidelines for comparison.

Tabs & Indentation

Do not use hard tabs. (Commits may be prevented by a Subversion pre-commit hook.)

Indentation at each level is 4 spaces.

Operator Overloading

When a class supports operator overloading, then there should also be non-overloaded methods, like this:

class Foo 
{
public:
    bool equals(const Foo &other) const;
    bool operator==(const Foo &other) const { return equals(other); }        
}

Class Attributes

Accessors for class attributes should be called get_xxx().

Mutators for class attributes should be called set_xxx().

Naming

Please don't start things with underscores.

Jinmei has been using CamelCase for class names, and lowercase_with_underscores for methods and variables.

Imported Code

If you import code from another project, don't bother to change the code to match our guidelines unless you plan on editing it relatively heavily.