Archive for February 27th, 2010

Oracle Driven Development

Saturday, February 27th, 2010

Test Driven Development (TDD) creates code from concrete examples of inputs and expected results (outputs/state changes).

Clean room software engineering creates code and design from stimulus history and expected responses. It’s the same concept but with additional mathematical rigor.

What do you do if you have an existing implementation that does what you want but the code is messy? First, find a testable interface against the old code, then create a set of test cases against it (potentially automatically generated) and use that as your test oracle when doing code implementation.

Here’s an example. Say that you have an awesome algorithm implemented in some horrid code on a platform that isn’t very portable, say some code in MATLAB that calculates the cuteness of kittens. Now you want to have this implementation in a language that’s deployable, say NumPy. Now, the code is horrible so you cry every time you see it, but it’s correct because it was written by the foremost psycho-physicist specializing in feline cuteness.

So you whip up a test case generator that feeds in a bunch of pictures of kittens and uses the MATLAB code’s results as ground truth. From there you basically have a complete black box description of the system and can hack away.

This is the same as TDD, but you don’t do the work of figuring out the expected results from the inputs yourself.

I really should try this out on a project sometime, perhaps PyGP again.