ProgrammingGuidelines

Chair for Computer Aided Medical Procedures & Augmented Reality
Lehrstuhl für Informatikanwendungen in der Medizin & Augmented Reality

THIS WEBPAGE IS DEPRECATED - please visit our new website

Programming guidelines

Coding guidelines

Language

The common language at the Chair for Computer Aided Medical Procedures and Augmented Reality is C++ and English. A detailed document of coding guidelines containing rules and recommendations could be found in the SVN (\src\guidelines\)

Indentation

Use tabs at the beginning of lines (for a visual markup of nested code) only - one tab per nesting level. After you typed the first non-tab character, always use spaces and never tabs (also for grouping).

Naming Conventions

  • Start class/struct names with a capital letter and variables with a small case letter. Only capitalize the first letter of a new word inside a name. Do not use underscores inside names (except in member variables, see below). Example: myHmdDisplay
  • Precede non-static member variables with m_.
  • Don't be afraid of long variable names or comments. You may save a few seconds of typing using short text but other people will need much more time understanding your code.

Other

  • Use references (&) instead of pointers (*) whenever possible.
  • Declare references and pointers by putting the ampersand or asterisk to the type, not to the variable:
    SomeType& someVar; SomeType* anotherVar;
    This is not only more logical (someVar is a pointer to SomeType) but also prevents errors when using doxygen, e.g.
  • Use const parameters whenever appropriate.
  • Never use NULL, TRUE, or FALSE but 0, true, and false instead. Testing a pointer whether it has already been initialized can be done like this:
if (myPointer) {
   // pointer is set => pointer value != 0 => evaluation to true
}
if (!myPointer) {
   // pointer is not set => pointer == 0 => evaluation to false
}
  • Never double code. If lines of code reappear, you can usually "outsource" them to a new method and call this method multiple times.

Version control system

Please refer to this document for more information on version control systems at the chair.

Code documentation

Use Doxygen style to comment all of your code!

Paths

Each project is checked in the CVS repository as a CVS module. Directory names are not allowed to have white spaces. Use capital letters instead (e.g. Don't 'My project' Do 'MyProject'). In each module there is a path with documents, source, doxygen, (if necessary) binaries. I propose two kinds of repositories:
  • Internal repository for chair members on rayhalle1
  • Students repository for students (Diplomarbeit, Praktikum, SEP, IDP our libraries) on atnavab5

Word processing

Official text documents are created with pdfTeX. Our editing IDE is TeXnicCenter. Unfortunately, the computers in the computer pool have WinEdt installed that provides the same functionality but it is commercial. Also possible is MS Word 2002 for easier interaction with external people.

Impotant Notes

When programming and especially compiling libraries with Visual Studio .NET you must take care that the 'Runtime Library'-Flags in the library and any program that uses the library are exactly the same. This is very (!) important. Otherwise you will get a lot of errors. You can find the switch under the 'Project settings' -> 'C/C++' -> 'Code Generation' -> 'Runtime Library'. I am currently using the flags /MT and /MTd. If any of you knows a good reason for changing this please tell us. Otherwise I would recommend, if we could agree up on these settings and thus won't run into intenal incompatibilities.

Camplib & TNT resp. JAMA

Some of our libraries need the Template Numerical Toolkit and the JAMA header files in order to compile properly. You can download them here. Please do not (!) include the references to the header files in your projects because we want to be able to store the files at different locations. Instead set the reference to these files under 'Tools' -> 'Options' -> 'Projects' -> 'VC++Directories' -> 'Show directories for:' -> 'Include files'.

Edit | Attach | Refresh | Diffs | More | Revision r1.20 - 23 Apr 2013 - 11:47 - AlexandruDuliu

Lehrstuhl für Computer Aided Medical Procedures & Augmented Reality    rss.gif