-
use fairly short, easy to read identifiers for high-use, limited-scope variables
-
use longer, more descriptive names for less often seen identifiers
-
use variable names that give an idea of their purpose (see K&R for examples)
-
ensure identifiers are long enough and different enough to be easily distinguished
-
ensure identifiers are easily remembered (i.e. not a random jumble of letters)
-
give a full description of the purpose of a variable in a comment where it is declared
Taken from an article on programming C but you will see this in practice in Clojure as well:
(def clojars-all-packages-uri "https://...")
(defn take-packages
[p]
(let [pkg [...]
uri clojars-all-packages-uri ]
(do something uri (else uri (or uri...)))))
First a longer (global) immutable string variable with a longer name, then below inside the function definition, the parameter names and local lexical scope member variables are rather short p
, pkg
etc.