(merge a {:a 1 :b 2})
-> (assoc a :a 1 :b2)
(-> foo (merge {:foo :bar})
-> (-> foo (assoc :foo :bar))
Reasoning:
- Performance
- Easier to read?
(assoc-in m (concat [:foo :bar] path) v)
-> (update-in m [:foo :bar] assoc-in path v)
Reasoning:
- Performance
- Easier to read?
(assoc-in m [:foo] v)
-> (assoc m :foo v)
(get-in m [:foo])
-> (:foo m)
(update-in m [:foo] f)
-> (update m :foo f)
Reasoning:
- Performance
- Easier to read
(clojure.string/split v #"/")
-> (str/split v #"/")
Reasoning:
- Easy to accidentally use namespace that is not required
- Even with core ns that are always available, good practice to ensure they are required
(if x
(f 1)
(f 2))
=>
(f (if x 1 2))
(re/reg-sub :view
(fn [db _]
(get-in db [:view])))
=>
(re/reg-sub :view
(fn [db _]
(get-in db [:view])))
Reasoning:
- Easy to forget to configure IntelliJ
- Needs a way to configure indentation for special forms?
- Macro definitions might contain metadata: https://github.com/metosin/compojure-api/blob/master/src/compojure/api/core.clj#L58-L67