Fork me on GitHub
#clojure-spec
<
2017-09-23
>
jstew19:09:55

Where is the canonical place to put specs? I read that clojure.core has them in a clojure.core.spec namespace . I'm thinking of making a separate namespace of .spec for each namespace in my app. But I will have some common specs (boilerplate stuff), but don't know where to put those. I'm not sure it matters since all of the defined specs are global.

gfredericks20:09:39

clojure is canon-poor

bbrinck20:09:39

I don’t know if there is a standard, but I’ve been putting them in the same namespace as the functions that manipulate the data. That way, other namespaces can require a single ns and get functions+specs

jstew22:09:46

@bbrinck What about specs that are shared between namespaces? Say you have a spec definition for a core.async channel or a map structure that's shared all over your app, do you duplicate that everywhere or keep those sorts of things in a single namespace

bbrinck22:09:26

In that case, I’d probably extract to a common “specs” namespace like you’ve suggested.

bbrinck22:09:55

It’s kind of like generic util functions. I’ll put them in a generic ns until some natural grouping emerges, then extract a more well-defined ns. YMMV