clojuredesign-podcast

Discussions around the Functional Design in Clojure podcast - https://clojuredesign.club/
nate 2020-11-14T00:47:54.059700Z

Happy Friday the 13th! New episode out today, wherein we talk about the times we would rather not be lazy. https://clojuredesign.club/episode/088-do-dorun-run/

🎉 3
Faris 2020-11-14T09:02:30.060500Z

3rd Larry Wall virtue is impatience

2020-11-14T14:52:27.062100Z

@neumann or @nate do y’all have any open source examples of good fiddle files? I understand the concept but wondering what they look like “in production”

nate 2020-11-14T17:36:30.066200Z

@ianjones here are a couple of examples: - https://github.com/app-sauce/fiddle-driven-development-2018-talk - source code that accompanied a talk I gave at the LA Clojure meetup. The fiddle files are in dev/fiddle, and the readme shows how to exersize them - https://github.com/jrwdunham/tegere - this is a library maintained by @jrwdunham, and you can see the fiddles in src/tegere/fiddle/ I found the second one with a github code search for fiddle, although that's mostly dominated by mentions of hyperfiddle.

2020-11-15T19:01:30.084300Z

Thanks for the replies! this was a super insightful conversation. I love how exploratory REPL driven development is.

2020-11-15T19:02:27.084500Z

I write a lot of Ruby for my day job and spend quite a bit of time in the ruby console building out what I want. Makes me want to ditch ruby and just use clojure 😛

neumann 2020-11-17T22:39:51.097900Z

@ianjones I can say that I've written a lot of Ruby, Java, Groovy, Scala, and Javascript, and now that I've been on Clojure for the last 4 years and ClojureScript for the last 1.5, I haven't really looked back!

2020-11-17T22:46:58.098300Z

have you recorded an episode on how you made that transition?

jrwdunham 2020-11-14T18:47:10.067100Z

That's funny. I learned the concept of fiddle files from listening to your podcast. Very helpful idea for me — thanks!

jrwdunham 2020-11-14T18:57:47.067300Z

I'd be interested to hear your thoughts on the tension between tests and fiddle files (or "Rich" comments) in this context @ianjones. REPL-driven dev seems to encourage fiddling and evaluating as you build, and once you confirm that things work as you expect, testing seems unnecessary. But, in reality, sometimes tests are necessary or mandatory. So then you have to convert your fiddles to tests, and that can be inefficient. Wondering if you have strategies to mitigate this inefficiency, or if you don't really see it as a problem...

neumann 2020-11-14T21:38:25.068100Z

I think @nate has a way of automatically re-running tests when related files get saved, but I haven't done that yet myself.

neumann 2020-11-14T21:39:17.068300Z

I definitely agree that "fiddling" is for figuring out the code and testing is for pushing on the edge cases and making sure future changes don't mess stuff up!

neumann 2020-11-14T21:47:30.068800Z

Another example of a "topic" or "workflow" fiddle:

(comment
  ; Re-create all the EDN tables from the tables in the "stats-by-hero.csv" file
  (util/reimport-tables fiddle.stat-table/stats-file)

  ; Browse each of the stat tables to make sure they imported OK, the labels
  ; look OK, the stats are the right type, and they point to the right hero.
  (fiddle.stat-table/check-table :stat-card-6)
  (fiddle.stat-table/check-table :caster-6)
  (fiddle.stat-table/check-table :live-4)

  ; Dump out the raw data for reference. (Not terribly useful.)
  (fiddle.stat-table/dump-table :stat-card-6)
  (fiddle.stat-table/dump-table :caster-6)
  (fiddle.stat-table/dump-table :live-4)
  )

jrwdunham 2020-11-14T21:51:37.069Z

Oops, I referenced Ian when I meant to ping @nate and @neumann. Anyway, thanks for those examples and elaboration.

jrwdunham 2020-11-14T23:43:25.069200Z

@neumann I use spacemacs and cider and can run a namespace's tests or a single deftest with a keyboard shortcut, so I think I get equivalent functionality to what you're describing with vim and fireplace. I too end up following a workflow (though maybe I hadn't formalized it as carefully as that) similar to what you itemized, and I've definitely been writing those kind of "topic" comments in repl/fiddle namespaces of late...

jrwdunham 2020-11-14T23:47:33.069400Z

In particular, though, I've noticed that "fiddle" code does not readily lend itself to direct translation into "test" code. I've ended up in situations where I end up writing a test assertion as:

jrwdunham 2020-11-14T23:47:39.069600Z

(is (->> (copied-from-fiddle-file ctx)
           run-assertions
           (every? true?)))

jrwdunham 2020-11-14T23:48:26.069800Z

which is not ideal in terms of the insight into what is going wrong in run-assertions

nate 2020-11-14T23:50:48.070100Z

I agree, I don't often copy code from fiddles to tests

nate 2020-11-14T23:51:24.070300Z

fiddling is more about exploration, testing is about locking functionality in

🔥 1
nate 2020-11-14T23:51:39.070500Z

I spend time in fiddles where I figure out where something is going

nate 2020-11-14T23:51:57.070700Z

and once I get there, I will decide whether I need to write tests about it

nate 2020-11-14T23:52:20.070900Z

and writing tests is like setting up wooden forms and pouring concrete around the implementation

jrwdunham 2020-11-14T23:53:21.071100Z

nice simile 🍷

nate 2020-11-14T23:54:09.071300Z

I never really understood TDD before clojure, and fiddle files have really convinced me that it's untenable

jrwdunham 2020-11-14T23:54:20.071500Z

yeah, so maybe the temptation to seamlessly merge fiddle code into test code should be resisted

jrwdunham 2020-11-14T23:55:36.071700Z

interesting. So any generalizations on how you decide whether something needs tests? Do you write property-based tests regularly?

nate 2020-11-14T23:55:43.071900Z

yeah, just because they both exercise the code in multiple ways doesn't mean they are identical and should share implementation

nate 2020-11-14T23:56:49.072100Z

if it's a smaller transform or I/O, I usually don't write tests

nate 2020-11-14T23:57:10.072300Z

they can cause an inertia in the code that is antithetical to progress

nate 2020-11-14T23:58:59.072500Z

usually if it's something particularly core, like decoding a bespoke data format, or a pure engine (such as one that will combine and aggregate sports stats from multiple games into one set), I'll write tests to make sure that it will continue to work when we need to change it in the future