Test Driving my Mage

15 07 2010

Mage being my favorite acronym for the moment; Math And Geomatry Engine. Makes me laugh anyway…

I’ve been thinking alot about TDD [writing alot about it as well] and have noticed I’ve already gone through several stages of coding practices using it. The first of which was simply write as many tests as possible, for every class, function and stuffed toy I had lying around. I’ve even tried to convince my wife to test-drive her social science essays [didn’t work out, I guess assuming the essay is complete, writing a test to make sure and then trying to fill it out doesn’t really work, but I digress]. In my readings of blogs I’ve come across Noel Llopis’ excellent GamesFromWithin; in it he writes alot about TDD and game development and one thing that caught my eye especially was his recommandation against test-driving a math library. I wasn’t sure why and after speaking to another friend decided that if it doesn’t help at least it won’t harm… It doesn’t harm at all, but trying to test-drive it showed, I think, a distinct lack of understanding for the reason to test-drive anything.

In my opinion, and correct me if I’m wrong, test-driving should be used when the starting point is defined, and you know where you want to end up – but you don’t know How. This means, in my book, that TDD should mainly be applied in places where functionality is not well defined, or not defined at all for that matter. Math code, vectors, matrices and their ilk have behaviour which is well defined, there’s simply no need to pretend otherwise. Test-driving objects such as a custom MovieList makes sense, we know what it eventuallty needs to have, but not how to achieve it, so we make assumptions and test-drive it; anything else is superlative.

Keeping in mind all that, I would like to add that I still think testing the library is very important. Making sure that we’ve achieved the correct precision levels and have properly implemented all the code is imperative to being able to optimize/refactor later without worrying about accidently adding the 3rd component rather than the 2nd.

Well, that’s it for tonight, I go back to my templates, my slowly evolving codebase and I still need to do the dishes!

One for sorrow, two for joy, three for boys and four for girls, five for silver, six for gold; seven for a secret never to be told…




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: