Coding Standards - ubtue/ub_tools GitHub Wiki

General Rules

  • format code like the rest of the code base; if there is a conflict between the file you're editing and the rest of the code base ideally reformat the file. If that is not easily possible, just be consistent with the rest of the file
  • indentation: we generally indent by 4 spaces per nesting level; tabs should never be used
  • line-length: our lines, irrespective of the language we are using, can be up to 160 characters long; we try to get by with less
  • two empty lines between functions, class declarations, import sections or anything else at file scope
  • please do not comment out code
  • we prefer carefully named entities to comments; clearly this is not always sufficient so please use your best judgement
  • we try to create the cleanest/clearest code possible; readability is just as important as correctness!
  • if you are unsure about how to format a particular construct and can find no consistent examples in the code base, please discuss it with a colleage (This can be in the form of a code review, if you wish.)

Language-specific Rules

Java

It seems that there is an inoffical, but widely adhered to, standard. We strive to follow this standard as long as it doesn't conflict with the General Rules

C++

Here we use a code-formatter with the following settings (PLEASE FILL THIS IN)

Python

Nothing beyond the General Rules for now.

Shell/Bash

We follow the General Rules. If you are unsure about how to format a particular construct, please have a look at other shell scripts.