TL;DR: Interested in using core.logic for test data generation? I may have the
"stunted framework" [1] for you.
--------
I've spent an entertaining few weeks learning core.logic and putting it into
practice. Because I learn by writing app-like code, I used it to generate
constrained hierarchical test data for an existing app.
The application under test reserves teaching animals at the University of
Illinois vet school. (Think meeting room scheduling, but with more and weirder
business rules.) I wrote a framework that (I hope!) makes it not-too-hard to
create data generation functions like this:
(one-reservation?> [[- {:days_delay 0}] [{:species :bovine} -]])
This reserves one "group" of two procedure/animal pairs. In the first pair,
we're happy to take any animal, but the procedure must be the kind of
low-stress procedure that can be done as often as you like. In the second pair,
we care nothing about the procedure, but the animal must be a cow. In all
cases, the procedure must apply to that species of animal. (It makes no sense
to float the teeth of a cow, as I'm sure you know.)
>From the above, we'd get something like this:
[ [ ["Genesis" "transabdominal ultrasonography"]
["Brooke" "physical examination"] ] ]
The strings are indexes into map-like data. It is a Small Matter of Programming
to turn the structure into an appropriate series of SQL inserts.
------
I think the results are promising. But the original application is written in
Ruby, so it's not like I can actually use this code in real life. I largely
wrote it to see whether test data generation would be a good case study for a
logic programming talk at Software Craftsmanship North America. I've concluded
it is.
So I'm OK letting this sit as is. If this might be of use to you, please to
read the wiki documentation I've written, make a judgment, and let me know:
https://github.com/marick/peano
--------
[1] "Stunted framework" is a term due to Michael Feathers: it's one that
doesn't try to be *so* universal that it's too hard to learn and too fiddly to
work with, but that also doesn't require so much coding that it doesn't save
you enough work. http://www.artima.com/weblogs/viewpost.jsp?thread=8826
-----
Brian Marick, Artisanal Labrador
Contract programming in Ruby and Clojure
Occasional consulting on Agile
www.exampler.com, www.twitter.com/marick
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en