« Can I Have A Law Named After Me? | Main | TDD, weeks later »

May 21, 2006



Tell us how it goes. I'm excited to try TDD as well in my next project. It certainly seems like it would be awesome for library / engine development. I'm pretty skeptical that it would be good for "game" development. Well, "good" is probably a loaded word. I guess rather I'm not sure it would be worth it. I just finished up my latest project with no TDD and I can only think of 2 or 3 bugs during the entire project that TDD would have caught and they didn't take anytime to find so clearly even a 5% hit for TDD let alone a 40% hit for TDD would not have been worth it.

At the same time, toward the end we were scared to make changes to the code and if TDD gave us the piece of mind to do it that might be worth something but I'm not sure TDD would have caught the type of bugs we were worried about creating.

As an example like many engines we used a signal system. One object had a both "go forward" and a "go backward" input. Signals could be used in a polling mode or a callback mode. In polling mode it was possible in some extremely rare cases for both of those signals to get set before the next polling intervol at which point the object in question had no idea which way to go, forward or backward, and if it choose wrong players could get stuck waiting for something that never would never happen. We fixed that by changing that object to use the callback method so it could know which signal came last. That fixed that bug in particular but we had no way of knowing if there were any places that counted on the old way of working and I'm not sure TDD would have found that problem. Maybe approaching it from a user point of view that TDD encourages might have helped but we knew about the issue (two signals coming in between polling intervols) when we coded it and we knew which of the two signals in that case took priority. We didn't think that was going to be a problem so I'm not sure we would have put in test that would have found the issue.

One thing "Practices of an Agile Developer" assumes is that the code in never done. That might be true for an engine and it's certainly true for a business apps but for games that't assumption is false. At least for console games the code is 100% done the moment it ships. There are no updates for PSP/PS2/GC/DS games. Xbox and 360 might cop out by supporting patches through live but not everyone subscribes to live so for most Xbox/360 games they also have a 100% done point as well.


The part that drives me crazy about TDD is when you need to test code that relies on a number of other systems, assets and the like. I write tests and use cases during the design phase, but I can never convince myself to go the full TDD route, and just end up with the old contract / assert way of ensuring robustness.

(I got a strange error in xml form while trying to post this)

Noel Llopis

Jamie, glad you found UnitTest++ useful.

Applying TDD to an existing codebase can be quite a challenge, and Jare's comment is quite valid. But once the codebase has changed enough, or if it was built with TDD from the ground up, then you don't have to worry about testing code that relies on a number of other systems... because you didn't design it that way.

I keep saying it, but TDD for me is not about making sure you have no bugs, but about designing your code from the outside. And giving you a simple, reliable, and incremental way of changing your code.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.


Post a comment

Your Information

(Name is required. Email address will not be displayed with the comment.)

Jamie's Bragging Rights

  • Spider-Man 2
    The best superhero games of all time Game Informer
    Top five games of all time Yahtzee Croshaw
    Top five superhero games of all time MSNBC
    Top 100 PS2 games of all time Official Playstation 2 Magazine
    1001 Games You Must Play Before You Die Nomination for Excellence in Gameplay Engineering Academy of Interactive Arts & Sciences
  • Schizoid
    Penny Arcade PAX 10 Award
    Nominated for XBLA Best Original Game
    Nominated for XBLA Best Co-Op Game