Project

General

Profile

Best practices for coding

Coding Style

Variables

  • Comment your code
  • Use descriptive variable and file names, use full words with_underscores_in_between or useNerdCaps.
  • If the long variables bother you while typing, get an editor with tab completion (e. g. XCode on Mac).

Functions / Methods

  • Split a method into sub methods whenever it is getting lengthy. AS a rule of thumb, one should always be able to view the code of each method as a whole on the screen without having to scroll. if it gets longer, split it and give descriptive names to the sub methods.
  • Aim to write generic submethods, so that they may be reused somewhere else.
  • Do not rely on global variables (with the exception of mathematical constants). Each method should only need its input arguments for computation.

Units

  • Physical quantities are always in SI units without prefixes: wavelengths in meters, fluxes in J/s/m^2.

Misc

  • The data files are only accessed at the beginning and end of each top-level component. Between submethods of a component, data is passed as local variables only.
  • Comment, comment, comment