Coding conventions

Naming Convention

Names of templates/classes/functions to start with an uppercase letter Store<Atom>, class Atom, GetResname() unless they are standard library extensions inverse_cholesky, numeric_vector.

Indentation

*NO* tabs. Indentation is four spaces.

See our emacs page on how to set it up in emacs.

CamelCase

Words within a name should start with an uppercase letter. For example, AddToResidue and GetNextAtom are both OK.

The first letter of Variable and data names should be lowercase firstAtom, nextProtein, atom, *molecule are all OK.

Files are by default named the same as the class/type. Header files has the extension .h and class files .cpp, all lowercase.

Defines in header files are written all uppercase, if the name of the class is AtomBomb the file name is AtomBomb.h and this would be the std:

#ifndef _ATOM_BOMB_H_
#define _ATOM_BOMB_H_

class AtomBomb {
public:
  // Methods here

private:
  // Methods here

};

#endif

When including something from standard libraries use <>, example: #include <vector> when including own headers use "" like this: #include "MyOwn.h"

Good Practice

Every class should have a constructor, a destructor and a copy constructor defined by the programmer. For example, here are three constructors for the Atom class:

Atom()                          // constructor for new atom
virtual ~Atom(void) {}          // destructor
Atom(const &Atom old_atom);     // copy constructor


Use static const instead of the old #define. For example:

static const float atomicMass;


Use string from The Standard Library:

#include <string>

rather than the old

char*


Use <iostream> for standard IO (cout/cin) instead of the old printf/scanf.