Fork me on GitHub
#off-topic
<
2018-07-11
>
jjttjj21:07:40

if you're wrapping a REST api, what factors dictate weather or not you convert all named parameters to kebab-case or just leave it camelCase

jjttjj21:07:58

these would be in maps users pass to my api wrapper

jjttjj21:07:39

im leaning towards just keeping {:camelCaseKeywords ...}

oscar21:07:30

If you're writing an api wrapper, I would go with kebab-case. Or you could accept both. But the point of a wrapper is to bring everything into the Clojure world and kebab-case is the naming convention in the Clojure world.

oscar21:07:22

Tangentially, I haven't used an API wrapper for a while. Instead, I like to use https://github.com/oliyh/martian

dpsutton21:07:39

there's a big thread on clojureverse talking about keywords and boundaries between different systems and languages

leblowl21:07:57

@jjttjj I've been thinking about this a lot lately. With a Clojure server (REST HTTP API/SQL DB) I am converting from PostgreSQL column names (snake_case) to Clojure kebab-case and then to JSON snake_case (make it easier for JS clients). I have a function that recursively updates key names at every boundary. Kind of a pain in the butt (and if your JSON/JDBC lib doesn't have a direct hook then you may end up walking the same data structure twice). Edit: my logic was to try to keep each data format in the most idiomatic style for each language/context at the cost of conversion

jjttjj21:07:26

yeah it makes sense regarding the idioms of the language. What has given me pause lately is that datomic uses camelCase keyword terms

mikerod21:07:41

another problem is that it seems like a big waste of time to keep converting things

mikerod21:07:09

it has always bothered me, but it extends a bit beyond just clj since there are so many naming conventions in play

mikerod21:07:27

except clj is somewhat “unique” in that it uses kebab-case, which some langs can’t deal with

mikerod21:07:32

(for identifiers)

jjttjj21:07:33

in the past i would always convert things. But there are always edge cases that must be accounted for ("PnL", etc) and effort going into something that at the end of the day doesn't matter a ton

mikerod21:07:58

and converting CamelCase like HTTPThing is always fun

mikerod21:07:07

h-t-t-p-thing 😛

jjttjj21:07:23

also not converting allows you to leverage the host docs mabe with a little less mental overhead required for the user

mikerod21:07:37

messes up with searching yes

mikerod21:07:56

but on the flip-side, if you have a bunch of non-idiomatic keywords in your code, may cause subtle mistakes

mikerod21:07:12

(:woops-forgot-this-is-camel-case m)

leblowl21:07:56

I think camel case is the most universally supported... maybe I should just get in the habit of using it more for naming SQL columns and JS objects... would sync with Java naming as well

leblowl21:07:18

and just keep the camel case within CLJ

justinlee21:07:22

for postgres the pain is having to put everything in doublequotes. for me, having mixed / inconsistent / unidomatic identifiers isn’t that annoying, but having to quote everything is a nightmare

john22:07:27

IMO, if the next resting place of the data is in clj/cljs land, kebab it. If you're pulling in json with lots of camels and you have to return the same camel json as fast as possible, converting might be prohibitive, depending on requirements.