Skip to main content

Test Driven Learning

Posted by davidrupp on March 30, 2005 at 10:15 PM PST

Mike Clark is on to something. If you know Mike, this won't come as a surprise to you. If you don't know Mike, you should start reading his blog, and this entry in particular. Go ahead and take a look at it now. I'll wait.

Yes, I know he's talking about Ruby, as well as unit testing, two topics that are pretty much guaranteed to raise the ire of some of the regulars on this site. After all, we're supposed to be about Java right? Java, Java, Java! And Unit Testing? Please. That is sooo 2003!

Well, it seems to me that the technique Mike is using to learn Ruby could be applied to any language, including Java. You might even call it "Test Driven Learning", if it weren't for the unfortunate fact that the phrase "Test Driven" in front of anything is sure to send the zealots (pro and anti) into a fruitless frenzy of name-calling and acrimony. And it's not really about unit testing; it just happens that Ruby has a built-in unit testing framework that makes it easy to setup and run these kinds of tests.

The principle behind all of this is very similar to "Exploration Tests", an idea that Stuart Halloway has been talking about for a few years now. Exploration tests aren't meant to be as robust or foolproof as unit tests. In a way, they're complementary -- they don't tell you what to expect in the future, they tell you what you've already learned (or are in the process of learning). They don't tell you how the system should behave, they tell you how it does behave.

Most importantly, they give you a way to learn the way your brain is built to learn, by experimentation. For more (and better) information on this topic, take a look at Kathy Sierra's blog, and particularly this post about just-in-time learning versus just-in-case learning.

This technique is the moral equivalent of hauling out your chemistry set and mixing chemicals together at random, just to see what happens. Or focusing your magnifying glass on that pile of dead leaves. Or adjusting the angle of the ramp to see if it helps you jump your bicycle over your brother, your sister, and three of your friends. [P.S.: Yes, these are actual childhood experiences. No, I am not necessarily proud of them. I blame my parents for giving me too much unstructured time.]

So take a little time to think of some ways you can express some knowledge and/or curiosity about Java in the form of a test. Think of an API you're not quite sure about and go make yourself sure about it. And know that you'll be able to save that snippet of knowledge so you can come back to it later and verify it at will. Now that's an activity worth investing some time and effort into.