It's in Your Blood
This weekend I wrote a simple helper application that is supposed to divide a file with several SQL-scripts to several files. Nothing serious, but the work gave me two insights.
The first one is, that it always, always, takes me half a day to re-learn the Regular Expression syntax. No matter how many times I used them, the next I'll need them I will still stare at the MSDN examples trying to figure out what's going on here. These magical strings are so goddamn incomprehensible.
The second one, and the subject of this post is, that I don't know how to write code without writing tests anymore. At first, I have to admit, I didn't mean to write tests at all. For this small a tool, I thought I would just spray some code and get it over with. But I couldn't. I was about to start coding when I thought that - wait, If I don't write any tests, how would I know that the code even works? I won't.
So I tried to recall how I used to work, in my pre-TDD days. I realized that what I did was: 1. Write all of the code, including the UI, without running it at all. 2. Start debugging. Now that's seems rather silly. Why not write working code to begin with, and also gain tests that will accompany the code until forever?
So I wrote the tests, and the code. At the end - everything worked from the first run. I didn't have to use a debugger at all. So what if this is a just a small app. There just doesn't seem to be another way to work anymore. It's in your blood.