Skip to content
ggallin08 edited this page Sep 21, 2014 · 1 revision

Code Style Guide

The following sections detail the standards that all code should be adhering to. Please attempt to follow all style and coding conventions in your packages in order to allow smooth integration of your code into the master repository. Following these conventions will also make it easier for others on the team to read your code and quickly understand it.

C++ Style

The order of preference to greatest to least for the C++ Style conventions is as follows:

  1. This document
  2. ROS C++ Style Guide
  3. Google C++ Style Guide

In otherwords if there is a conflict in any of the documents use the rule in the document with the lowest number.

Python Style

The order of preference to greatest to least for the C++ Style conventions is as follows:

  1. This document
  2. ROS Python Style Guide
  3. Python PEP 8

In otherwords if there is a conflict in any of the documents use the rule in the document with the lowest number.

Readability

Readability should be the number 1 priority in almost all cases. Some exceptions include when profiling has shown that optimizations must be done in order to get the desired performance from a section of code. Most of the time the compiler will do a good job of optimizing readable code by itself.

If you are concerned about performance you can profile your code using tools such as valgrind. See the Profiling section of this wiki for more info.

Documentation

Code should have doxygen comments. See the Documentation section of this wiki for more info.

Behavior Testing

When writing code keep in mind the ease of testing. Try to write code so that unit tests and integration tests can easily be written. For more information on testing see the Testing section of this wiki for more info.