Fork me on GitHub
#fulcro
<
2019-07-06
>
pithyless11:07:38

OT: I see Fulcro3 is using ghostwheel >defn et al. Any chance for a short field report on how useful it has been in practice? Is it worth introducing into new / existing projects? Has it been a mental overhead vs using plain defn (and maybe fdef / test.check explicitly)? I see about 20% of functions are >defn the rest still defn; is that mainly due to writing only new code with >defn or is there a heuristic for what gets specced?

currentoor15:07:03

Tony and I are working on SaaS product using fulcro and ghostwheel. We added it after building a substantial portion of the project. I would say it’s worth it.

currentoor15:07:54

fdef does not check specs on return values right? We feel that is useful, though I’m sure Cognitect has their reasons.

currentoor15:07:31

IMO to get your money’s worth you need to have a thorough and concise behavior driven test suite. Then when you change code you can see very obviously where your assumptions are inadvertently being broken. It starts to behave like a “type system” then.

👍 4
currentoor15:07:01

Because of this I write most of my business logic (and tests) in CLJC, even if it’s primarily used in in CLJS just because Clojure has better IDE integrations.

👍 4
currentoor15:07:34

Hope that helps

pithyless17:07:57

Thanks @U09FEH8GN - that helps. True, fdef by default only instruments arguments, not returns, but that can also be achieved via orchestra/defn-spec, provisdom/defn-spec and others. The other benefits are (1) automated test.check tests and (2) tracing. I was curious if you were also using ghostwheel for (1) and (2) (and how that compares to just writing defspecs yourself and maybe using tools like debux)

currentoor17:07:20

Oh also you’ll want to use something like expound to format the error messages nicely, the default error reporting is really hard to parse

👍 4
pithyless17:07:51

I was actually thinking of the reverse case that you described: is it worth writing business logic in CLJC just so we could use ghostwheel tracing in CLJS, even if we primarily intend to run it on the JVM (of course then we're limited to things that have no JVM interop)

currentoor17:07:46

Tony and I were talking about (1) yesterday, so far we haven’t really found a use case for it in our SaaS product. To us it seems like automated testing is better suited for certain algorithmic tasks especially when you have a known, but slow, reference implementation to use. And encoding/decoding functions.

pithyless17:07:57

I've primarily been using expound with orchestra/defn-spec and more recently provisdom/defn-spec for instrumenting inputs and outputs. It's been useful, but sometimes I struggle with the amount of "additional syntax" that appears around functions.

currentoor17:07:10

getting automated tests for typical SaaS application might be possible but getting the generated data right seems like such a big investment, since most of our function aren’t meant to operate on generic data, instead they operate on our model data

pithyless17:07:26

It's definitely useful on primary API functions, but I can't find myself wanting to spec every function I write

currentoor17:07:02

yeah i like how concise ghostwheel is

currentoor17:07:18

makes it easy to spec most functions, because why not?

currentoor17:07:35

also by trancing you mean measuring performance right?

pithyless17:07:00

no, by tracing I mean debugging forms

currentoor17:07:25

oh like figuring out where a function spec was violated?

currentoor17:07:50

oh i didn’t know of that, that’s really cool

currentoor17:07:54

thanks for sharing

pithyless17:07:36

in GW that only works in CLJS - I was hoping you two could tell me more of how useful it is in practice ^_^

pithyless17:07:02

@U09FEH8GN RE: generating domain-specific data we've been using https://github.com/reifyhealth/specmonstah to reduce the boilerplate and still allow us to write property tests

pithyless17:07:34

But again, even in this case... you need some amount of test setup / configuration / generator customization - so it sounds like something you would not use directly from ghostwheel fn specs

wilkerlucio18:07:07

@U05476190 I have been using ghostwheel in a recent project, I'm loving it, you can setup it so it instrument both inputs and outputs, its very nice it integrates humanize errors, and it works good in Clojure too, I'm using on both cljs and clj, great experience IMO

👍 16
tony.kay03:07:09

@U05476190 My initial use of gw was to get the co-located specs and more concise syntax, but especially the ability to do instrument/outstrument with a global config instead of using the instrument function manually. The addition >def also makes it possible to more consistently and easily elide specs from a production cljs build (where they hurt the size of the artifact produced). You can use something like (when goog.DEBUG ...), but that doesn’t turn on/off with the ghostwheel settings, so is useless for CLJ and then you end up with more complex expressions in the when, etc. I’ve not used the tracing, because, well, I just haven’t felt the need. I’m sure I’d appreciate it if I used it, and will try it out soon, but the other benefits are plenty enough for me to justify it in my libraries.

tony.kay03:07:28

The benefits of having instrumented functions during development with good specs has been dramatically improving my dev experience, though I admit I’m still coming to grips with best practices.

tony.kay03:07:21

And as @U09FEH8GN said: Make sure you get the logging set up right for clj and cljs so the spec failures are good. See the new logging helpers in fulcro 3 for cljs…that really made a world of difference for me.

pithyless06:07:36

Eliding the specs from the CLJS production build is something I had not considered as a benefit of the >def approach.

pithyless06:07:44

Thanks @U09FEH8GN @U066U8JQJ and @U0CKQ19AQ for the field reports!