Fork me on GitHub
#clojure-spec
<
2019-05-06
>
yuhan19:05:41

Is it good practice to place all specs together in a dedicated my-project.specs namespace?

Jakub Holý (HolyJak)20:05:58

I do not know but on my project I created a separate .domain ns with specs so that I could share them with multiple namespaces and it is nice not to have it all through the core ns. So it works for me 🙂

yuhan20:05:16

Thanks! I was reading a few posts and it seems there isn't really a one "correct" way of doing things

yuhan20:05:48

sharing specs between namespaces is the reason I'm thinking of doing it as well, and it probably makes sense for s/fdef specs to remain next to their respective functions

👍 8
butterguns18:05:24

I personally put specs above the code, in the same namespace. It makes sense that logically, if I want to see the "Event" spec, it would be in the event.clj namespace for example

butterguns18:05:35

I also have a common.clj namespace, which contains shared functions. It also contains common specs, like ::timestamp, which is used in many places

rickmoynihan15:05:24

I’d say it can make sense for libraries at a certain scale… though even there you may just want to put them where you need them. For an application you’ll inevitably end up wanting to spread things out.

yuhan19:05:34

I also avoid using namespace alias ::keyword syntax and most of the specs have short 3-8 character prefixes that don't actually correspond to any of my project namespaces, wondering if that's good practice too

Jakub Holý (HolyJak)20:05:25

They don't need to correspond to actual namespaces, the main thing is I guess readability.