[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: case against XP (was: PG: Hackers and Painters)

Sundar Narasimhan writes:
> Stated differently, what percentage of the tests you wrote in TDD/XP
> were truly meaningful, or were you somehow smart enough during the
> initial stages of a project to write truly useful tests right from
> the get go :)

About third to a half of my tests discover bugs in the initial
implementation. But the rest still to useful work -- they serve to
confirm that my fixes really work generally!

I also use tests to develop incrementally. For example, I will write
some tests for the simple cases, and then write some code that solves
the simple case. Then, I write some more tests for more complex
inputs, and then update the implementation. When I rerun the whole
test suite, I confirm that my additions didn't break what was already

For me, tests work like a REPL with memory.  A lot of my hacking was
(and is) trying things out at the interactive prompt, one expression
at a time. Nowadays, whenever I try out an experiment like that, I
immediately turn it into a test. This way I can have a permanent
record of my experiments: it's the programmer's equivalent of a
scientists's lab notebook, or an artist's sketchbook.

The most complicated program I've written in this style is Needle's
typechecker. It's only a few thousand lines of code, but it is far and
away more complex than anything I've ever written before, and anything
I've seen in common commercial use. It let me find a very subtle bug
in the unification algorithm I was using, which I doubt I could have
figured out in any other way.

Neel Krishnaswami