Coding Style Guidelines

We won't be ultra strict about these but please try to follow them. If you don't we will probably make you rewrite your code until you conform. The basic rule is that you should conform to the already existing code and keep with the conventions that they have written.

  • Using _'s naming for coding style, since the library functions already use this.
    • i.e. usb_puts.
    • Gregory Tress defines whatever he wants for Java.
  • Put brackets on the same line.
  • Use four spaces for soft tabs.
  • 120 character limit per line. Break things nicely over multiple lines.
  • Files should terminate with just one new line.
  • Don't use macros unless you have to.
  • Use one space after if, while, =, operators, etc.
  • Use meaningful variable names, don't use abbreviations
    • Unless they are well-known and unambiguous.
  • Method and variable names start with a lower case letter.
  • Names of constants should be all uppercase with underscores. In C #defines should be used for constants.
  • Code should be commented and also use doxygen comments.
  • Put spaces between parameters in functions. i.e. function(param, param);
  • Header files should contain constants and function prototypes. Don't create/include unnecessary header files.
  • For things not listed as rules, keep them consistent within the file.
  • Prefer C99 data types (uint16_t...) over traditional types (int...). See AVR data types.