Skip to content

Instantly share code, notes, and snippets.

@clojens
Last active August 29, 2015 14:07
Show Gist options
  • Save clojens/c6d346841b00862eab8d to your computer and use it in GitHub Desktop.
Save clojens/c6d346841b00862eab8d to your computer and use it in GitHub Desktop.
golden rules?
  1. use fairly short, easy to read identifiers for high-use, limited-scope variables

  2. use longer, more descriptive names for less often seen identifiers

  3. use variable names that give an idea of their purpose (see K&R for examples)

  4. ensure identifiers are long enough and different enough to be easily distinguished

  5. ensure identifiers are easily remembered (i.e. not a random jumble of letters)

  6. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment