clojure-europe

For people in Europe... or elsewhere... UGT https://indieweb.org/Universal_Greeting_Time
javahippie 2021-02-19T07:49:24.467600Z

Good Morning!

ordnungswidrig 2021-02-19T08:00:01.467900Z

Good morning!

slipset 2021-02-19T08:03:34.470Z

An interesting effect of clojure-lsp and lenses is that I’m made aware of fns which only are used once. I find that a bunch of them are quite useless and an indication of something to be fixed.

👍 1
reefersleep 2021-02-19T08:42:55.470500Z

Indeed! Helper functions can be nice, but are often superfluous, I find - and can be inlined.

dharrigan 2021-02-19T08:48:42.470800Z

Good Morning!

djm 2021-02-19T08:54:38.471Z

👋

2021-02-19T08:57:47.471100Z

the upside is one less thing to name and the downside being that your function is longer and lacking in a meaningful name?

2021-02-19T08:57:54.471400Z

morning

2021-02-19T08:57:58.471600Z

:morning:

slipset 2021-02-19T09:06:16.471700Z

There are some other upsides, but I haven’t quite been able to formulate it. Sometimes it’s a too specialized fn, ie something like:

(defn find-by-name [db name]
  (query! db {:name name}))

2021-02-19T09:10:37.472Z

fair enough. Depends on the length of the helper I suppose

thomas 2021-02-19T09:47:46.472300Z

morning

reefersleep 2021-02-19T09:57:00.472400Z

Exactly, @otfrom. I loved making helper functions when I first started learning Clojure, but now that I’m more comfortable with the core, I prefer a larger function body than loads of names for arbitrary bits of code - it’s harder to come up with them, and it’s harder to read (remember) them. Generality of the helper functions, like I believe @slipset is talking about, also weighs in on the matter. I feel like the more your helper functions feel like an extension of the Clojure core in terms of naming and behaviour (like nil punning), the better. It’s never black and white, of course 🙂

👍 1
slipset 2021-02-19T10:06:40.472600Z

Also, our fns which look like the above have had a tendency to be like:

(defn find-by-lots-of-things [db foo bar baz qix and some other stuff]
  (query db ...lots of calculations to make the query)) 
Which then (IMO) is better done as:
(defn query-for-lots-of-things [foo bar baz qix and some other stuff]
  ...lots of calculations to make the query)
The upside to this is that suddenly you (if you use honesql or some other data based query language) have composable things which lets you write:
(->> (query-for-lots-of-things foo bar baz qix and some other stuff)
     (merge (by-id id)
     (query! db)

👍 2
raymcdermott 2021-02-19T10:37:10.473600Z

Morning

borkdude 2021-02-19T10:42:42.473800Z

Morning

reefersleep 2021-02-19T11:38:21.474500Z

Always Be Composing 🙂

reefersleep 2021-02-19T11:39:09.474700Z

That’s a good rule in general, I think. Leave the composition to the caller.

reefersleep 2021-02-19T11:39:29.474900Z

Insofar as possible.

pez 2021-02-19T16:49:45.478300Z

Morning folks! I posted this in #babashka, but think it fits here as well. I often search for “clojure” on Youtube, filtering on newest first. Today I tried another filter. It’s that dude we all admire and love. 😃 ❤️

8