Skip to content

Contribute

Daniel Riissanen edited this page Aug 8, 2016 · 2 revisions

Principles & Values

Modular: The project aims at being modular and providing fine-grained control for the user. This means that all scripts are supposed to work independently by either using configuration files or command-line arguments as data. Exceptions are utility scripts containing common functions and global variables. These can be sourced into other scripts when needed.

Defensive: All of the scripts are to be written defensively, meaning that nothing will be assumed and everything is checked. Examples are file and directory existence checks. If something fails, restrict functionality from the user. Functions are to return as quickly as possible.

Readable: One of the important things about code is that it is read many more times than it is written. The code has to be readable and easy to understand. Practically this means that variables should be named well, no 'aa' variables. Functions are short and do one thing only. The function name should convey the purpose of the function.

Intuitive: Since the scripts are used by humans it is important that the usage is intuitive. If the user does not understand how to use the script after reading the help message it means it is not intuitive.

Code Style

There is not really any coding convention, except a few thumb rules:

  • Provide a help and usage message for every executable script
  • Global variables are capitalized
  • You can use the shebang #!/bin/bash
  • Try to use script return value as a measure if the script was successful

When editing an existing file, please use the same coding style.

Closing curly bracket of a function is followed by the name of the function. This makes it easier to navigate the document when searching.