Clojure Coding Guidelines

The primary motivation for most of the guidelines is code readability.

  1. Use two spaces for indentation.
  2. Select meaningful names for functions and variables. Avoid acronyms that aren't commonly known. The only acceptable one letter names are for the following variables: i for an index and x/y/z for cartesian coordinates.
  3. The names of predicate functions (returning a boolean) should typically end with a question mark (?).
  4. Prefer rewriting code to make it clear over adding comments. If that cannot be achieved, add comments.
  5. Limit the number of functions invoked in a single line of code to five.
  6. Limit the nested depth of a function definition to four. In order to achieve this it may be necessary to introduce local variables to hold intermediate results or extract code into additional function definitions.
  7. Only use anonymous functions for short function definitions that fit comfortably on a single line. Otherwise create a private, named function.
  8. Do not write anonymous functions that have arguments that are anonymous functions.