Yesterday I finally jumped into the trenches. I'm doing a small school assignment that should get help me improve my own software process. The assignment is based on PSP. However, I decided it's a good chance to concentrate on something completely different (heh). So, when I started actually coding the first assignment - a simple LOC counter - I tried to stick to TDD as well as I could.
And I can tell you, I haven't been that excited in months, or probably years. After struggling a bit with creating a new project in Eclipse (and setting some keyboard preferences and the like) I dived head-first to the world of agile development. (Ok, I know this sounds a bit over-the-top, but that's exactly what I felt like then!)
Of course I had thought about the assignment already a few weeks ago, but now I wanted to stick to the crucial basics of XP: do the simplest things first, implement only the things that you have to. So I started by writing a test that asks a method (that I had not, of course, even started writing yet) how many lines of logical code an empty line (or string) has. Naturally the assertion compared the method call to zero. I tried running the test before I any actual code ready. And it failed - woohoo! Next I wrote a simple, one-line method that compares a given string to an empty string, and if they're equal, returns zero. I actually ran into problems right away, because I had used the default package for the test and now included the actual code in a real package, so I had to move the test to that package, too (which meant creating a new package in test/src directory and moving the source file under that one). Even though the mistake was quite stupid, all I could feel was excitement about learning! I had not written any (serious) Java in a couple of months, so it felt really good to "get on the road" again.
And so I went on. I added a test with one line feed and ran the test, which failed. Then fixed the actual method to trim the given string before doing its comparisons, and again, the tests passed. And step by step, I added functionality to the method, always writing the corresponding tests first: not counting a single comment line, counting several statements on a single line as several lines of code etc.
Although I spent only a couple of hours doing the assignment before I had to do other things, the work really took off fast. And I can't wait to get my hands on it again (hopefully today)...