Exploration Through ExampleExample-driven development, Agile testing, context-driven testing, Agile programming, Ruby, and other things of interest to Brian Marick
|
Thu, 29 Jan 2004Suppose you have a set of tests, A through Z. Suppose you had N teams and had each team implement code that passed the tests, one at a time, but each team received the tests in a different order. How different would the final implementations be? Would some orders lead to less backtracking? I decided to try a small version of such an experiment at the Master of Fine Arts in Software trial run. Over Christmas vacation, I collaborated with my wife to create five files of FIT tests that begin to describe a veterinary clinic. (She's head of the Food Animal Medicine and Surgery section of the University of Illinois veterinary teaching hospital - that's her in the top middle picture at the bottom of the page.) I implemented each file's worth of tests before we created the next file.
An interesting thing happened. When I got to the fifth file (1D), I had to do a lot of backtracking. One key class emerged, sucking code out from a couple of other classes. I think a class disappeared. After cruising through the first four files, it felt like I'd hit a wall. I'd made some bad decisions with the second file (1A), stuck with them too long, and was only forced to undo them with the fifth file. (Had I been attentive to the small, still voice of conscience in my head, I might have done better. Or maybe not.) At the trial run, we spent four or five hours implementing. Sadly, only one of the teams finished. They did 1D before 1A. (Their order was 000-1D-1C-1B-1A.) What was interesting was that they thought 1D was uneventful but 1A was where they had to do some serious thinking. I got the feeling that their reaction upon hitting 1A was somehow similar to - though not the same as - my reaction upon hitting 1D. That's interesting. Here are some choice quotes: Brian: Am I right in remembering that D was no problem, but that things got interesting at A (which is the opposite of what I observed while taking them in the other order)?
Another pair had an experience slightly similar to mine. They did 000-1C-1B-1A and then started on 1D. One of them says:
What do I conclude from this? Well, nothing, except that it's a topic I want to pay attention to. I don't think we'll ever see a convincing experiment, but perhaps through discussion we'll develop some lore about ways to get smoother sequences of tests. If anyone wants to play with the tests, you can download them all. You'll also want the FIT jar file; it has a fixture I use in the tests. Warning: you will need to ask clarifying questions of your on-site customer with expertise in running a university large animal clinic. Oh, you haven't got one? Mail me.
## Posted at 11:32 in category /mfa
[permalink]
[top]
Sun, 25 Jan 2004My first event in the Master of Fine Arts in Software trial run was a lecture on code-reading in the style of the literary critic Stanley Fish. His "affective stylistics" has one read a poem (say) word-by-word, asking what each word does for the reader. What expectations does it set up? or overturn? What if that word were omitted or moved elsewhere? (I've written on a similar topic earlier, and I drew my examples from that entry.) I compared idiomatic Lisp code, "C-like" Lisp code, idiomatic C code, and Lisp-like C code to show how expectations and membership in "interpretive communities" influence readability. In the process, I learned something unexpected. I presented code like this to Dick Gabriel, expecting he would think it an idiomatic recursive implementation of factorial. (defun fact(n &optional (so-far 1)) (if (<= n 1) so-far (fact (- n 1) (* n so-far)))
He didn't think it was idiomatic, not really. He found it somewhat old-fashioned,
preferring an implementation that replaces the optional argument
with an internal helper function (introduced by
the (defun fact (n) (labels ((f (n acc) (if (<= n 1) acc (f (- n 1) (* n acc))))) (f n 1)))
Now, I always hated
The It's arguable that my reading style is just flat-out worse, but I do think that tuning reading to writing is a more useful way to think about it. All this may seem small, but it reinforces my idea that attending closely to the act of reading will yield some Aha! moments to improve our practice. |
|