Blank lines 1-2-3

Blank lines 1-2-3

Blank lines 1-2-3.

A service note for my colleagues explaining my thinking when I use 1-2-3 blank lines in the code.

I use 3 blank lines to create code sections. Sometimes, when the namespace grows these sections can move into separate files. If a section wants a header and additional commenting I do it like

(def x 4) ; end of a previous section

;;;;; Section Title ;;;;;

(defn section-fn [])

I use 1 and 2 blank lines to space out things inside sections and functions. In a function with a large let or branching block I can use one blank line to group local bindings or the code branches.

When that happens inside a function – the next defn must be two lines away, as the design rationale of spacing suggests. If the inner parts are separated by one line already, then the outer part must be farther away than that. Example

(defn combined-requests [params]
   (let [resp1 (http/get "/api/user")
          resp2 (http/get "api/etc")

          post-resp (http/post "/api/entries" {...})
          post-resp2 (http/post "/api/entries" {...})]
     {:status 200, :responses {:my/resp1 resp1 :my/resp2 :resp2 ...}))

(defn next-function [opts]
  (http/get "/api/else"))

It all helps to make the code more scannable.