dragonrobotics.github.io

Dragon Robotics Programming Style and Procedures

You can find the Operations Manual here.

Preface

This document is intended to be a living document and should be updated as new cases and situtations come to light.

The first and foremost rule to keep in mind when reading this document is:

The rules are flexible, but think things through before you bend them.

We can’t think through every single possible scenario, and for every rule we come up with a hundred exceptions will inevitably arise. On the other hand, however, each of these rules has a purpose. If you need to break a rule, you’d better have a really good reason for it.

Coding Style

There are a couple of basic rules that we believe should be followed by everyone, with regards to code format and styling:

Inline Documentation

We (are planning to) use Doxygen to automatically generate documentation from source code, no matter what language said code uses.

Doxygen can parse Javadoc-style comments. However, there are a few differences with Doxygen commenting vs. Javadoc commenting:

File Header Block Format

The first lines of all files should be a comment block containing the following pieces of information, in roughly this order:

  1. Opening @file tag and filename: only include parts of the path if the filename alone is not unique.
  2. Description: both brief and detailed descriptions should be included, separated by an empty line. Use of the @brief tag is optional: everything up to the first period and newline will be taken as the brief description if the tag is omitted.
  3. Author(s)
  4. Version: try to adhere to Semantic Versioning as much as possible.
  5. Date modified

An example is given below:

/**
 * @file example.cpp
 * A brief description of my example code.
 *
 * This file has a bunch of example code that does strange and informative
 * things and does a lot of other stuff too, I guess. This description is
 * trying to be very long winded. It also has *Markdown*. This was the detailed
 * description, and it fits within 80 character lines. This format stays the
 * exact same when writing in Java, too.
 *
 * @author John Smith
 * @author Haruhi Suzumiya
 * @version 3.14.159-alpha+572e52d
 * @date January 19, 2038
 */

Procedures

Git and Github

Please keep the following things in mind when working with Git and Github:

Continuous Integration

For most of us, there isn’t really anything to keep in mind, with regards to continuous integration (aside from remembering that it is always there and watching). It’s there simply to help ensure that problems don’t slip through the cracks.

There are three main things CI can and will do for us (specifically):

  1. Make sure the code actually compiles.
  2. Automatically generate documentation using Doxygen.
  3. Automatically check code style using linters or custom scripts.

We’re (planning to) use Travis CI as our CI system; it integrates with both Github and Slack, and seems to be a good, well-polished platform.

Automated Testing

Performing unit testing with robot code usually ranges from ‘impossible’ to ‘impractical’ or ‘very difficult’. Simulation-based unit or integration tests are out of the question:

Of course, this means that code that interfaces with hardware cannot be unit tested.

Thus, unit testing is probably going to be less of a priority with us, as compared to other software development groups. What little automatic testing we perform, however, can easily be integrated with Travis CI.