Fork me on GitHub
#clojure-spec
<
2022-02-23
>
jjttjj18:02:58

Let's say you have to integrate with several providers by providing them an endpoint the receives json from them and must return json. The json structures each provider gives you and expect back are pretty different even though the essence of the operation is always sort of the same, though each platform has its quirks. I attempt to smooth over some of the differences, and build out my functionality on a common internally use data structure. In these situations, do you bother spec'ing the structures given/expected by each provider? Or the internal common structure only? Or both? Originally I thought I could get away with focusing on only my internal structure, but I'm finding the platforms are different enough in complicated ways that I really want specs for each one. My usage of spec here is to aid in writing tests (not necessarily generative ones)

Colin P. Hill20:02:32

Since they don't turn domain changes into compilation errors like static types sometimes do, afaict the worst case scenario is that you decide later that keeping them up to date isn't worth the effort and just delete them. No harm in just writing them now if they're useful now, imo.

👍 1
Colin P. Hill20:02:09

Personally I'm a big fan of specs as a way of documenting data structures, even if I never use them for anything else. The fact that I can instrument them for tests and REPL sessions is just gravy.

jjttjj03:02:30

Makes sense, thanks!

Ben Sless07:02:13

Both. This lets you have a contract with them on one hand,a and verify your transformation to the common model on the other