Clojure Coding Guidelines
The primary motivation for most of the guidelines is code readability.
-
Use two spaces for indentation.
-
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.
-
The names of predicate functions (returning a boolean)
should typically end with a question mark (?).
-
Prefer rewriting code to make it clear over adding comments.
If that cannot be achieved, add comments.
-
Limit the number of functions invoked in a single line of code
to five.
-
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.
-
Only use anonymous functions for short function definitions
that fit comfortably on a single line.
Otherwise create a private, named function.
-
Do not write anonymous functions that have
arguments that are anonymous functions.