Fork me on GitHub
#interceptors
<
2022-11-04
>
onetom15:11:17

i find it annoying to write interceptor(s) and i see my colleagues, who are non-native english, to struggle with spelling it sometimes, so i was wondering, what would be a good abbreviation for it. 1. int? it already means integer 2. intc? as in int(er)c(eptor)? how would i pronounce it? intk? ints? int-see? doesn't evoke the original word for me... 3. intr? could work... short enough, but as an ex-microcontroller programmer, it just reminds me interrupt, as in the pins on ICs 4. inter? it's a whole, generic prefix word; could mean anything "in-between"-like, so not specific enough 5. intor? as in int(ercept)or? intors in plural. maybe...? 6. i9r? like i18n, internationalization style? not really guessable, but short and quite unique... plural would be i9rs. 7. don't abbreviate it and just put up with its length and the resulting wide, aligned maps :) for middleware(s), i used mw & mws and that worked reasonably well... what do u think?

onetom15:11:48

i would use it as 1. keyword map keys of course, but also 2. as namespace segments in ns aliases, like [company.ring.interceptor :as comp.i9r] 3. as part of var names of interceptor-maps, eg. company.ring/i9r:with-user or company.ring/with-user-i9r

jjttjj14:11:53

I use ix, which I believe I stole from code I saw in or using https://github.com/exoscale/interceptor, and have been happy with that abbreviation

👍 2
Proctor14:11:54

We used ix as well when I did Papillon, as it seemed to fix with transducers’ xf and using transactions with tx

onetom15:11:47

8. ixr? where x is like a wildcard char? it is short for trans usually, though, like xform, xfer, xf (*trans*ducer-*f*unction?)...

onetom16:11:32

not having a number in the name doesn't break the visual flow of the code so much as i9r and it's also easier to type...

onetom16:11:21

there are also these abbreviations in non-technical context: 9. INTCP 10. INCEP according to https://www.allacronyms.com/interceptor/abbreviated

onetom16:11:05

intercept, without the or suffix would be 1. INTCP 2. INTC 3. IC? might work in non-electronics related code, so it doesn't clash with *I*ntegrated *C*ircuit 4. I/C? 5. INT 6. INTC or? ...in 2 words? weird... 7. incpt according to https://www.allacronyms.com/intercept/abbreviated

onetom16:11:50

it's still a question of how to name interceptors. since they are a set of 1, 2 or 3 functions, it's tempting to name them using some verb, especially if they only effect either the enter or the leave phase only. but then, their name like a function name, so how can we tell them apart from regular functions? since we can use angle brackets in clojure symbols, i was wondering to adopt something like this: 1. <merge-query-and-form-params> — which would look like a HTML tag, so might be misleading, though the context probably disambiguates it 2. >merge-query-and-form-params< 3. merge-query-and-form-params<> 4. <>merge-query-and-form-params 5. query&form-request-params->params 6. query&form-request-params->params 7. |merge-params| — to hint at the 2 threads of execution, the enter and the leave phases 8. ixr:merge-params 9. merge-params:ixr 10. merge-params-ixr 11. i9r:merge-params

onetom16:11:43

the |merge-params| notation would also allow the indication of whether the :enter or the :leave phase is defined by the interceptor: for example, the muuntaja.interceptor/format{,-negotiate,-request,-response}-interceptor & muuntaja.interceptor/exception-interceptorcould be: 1. |format| 2. |negotiate-format_ 3. |format-request_ 4. _format-response| 5. _format-exception_| or _format-exception_! or _format-exception_err to indicate the presence of the :error phase only 6. |some-xform|| or |some-xform|! or |some-xform|err would be the name of a {:enter ... :leave ... :error ...} interceptor

onetom16:11:50

this notation would solve the problem of not knowing which phase of the execution chain does a specific interceptor contribute to. knowing that, it would be easier to imagine what is the correct ordering of the interceptors.