Programming while tired

I guess it happens to all of us. In theory, I make use of as many techniques as I can to mitigate against suffering from mistakes while I'm programming. I use Test-Driven Development, I make small changes and use frequent check-ins to my source code repository. Every now and then though, I lose the plot and this is what happened this evening. I had been out for the early part of the evening, so it was past 10pm when I sat down to work on the code. I was so keen on getting to the point where I could use ELIUS to define new words in ELIUS that I just hacked away.

Soon enough I found myself drifting from writing tests and making the code pass, to scratching my head and debugging. An hour and a half later I seemed to have only succeeded in making things worse. Even relatively simple bits of code which had been working for weeks suddenly started behaving strangely, and even adding more and more diagnostic output did not seem to help me find the source of the problem. I had changed so many parts of the code that there was very little I could rely on any more. By midnight I new I had to do something drastic, so I pulled the plug and rolled back everything I had written, back to the previous day's good code.

I can be heartbreaking to just throw away hours of intense work, but I have learned from experience that this is almost always a good thing to do. When I started again with a fresh, working, code-base I was able to address the problem in a much more sensible way. First I enhanced the diagnostics (tools to dump out the internal string pool and dictionary data structures in a readable manner) and made sure that they were working well and clearly, then divided up the problem of creating the word-defining words into smaller, more manageable chunks, both of code and of tests.

By 1am I had the basics of a working definition syntax, and 20 minutes or so later it was tidied up and checked in. I'll write more about how it all works tomorrow

PS. I'm cheating a little, in claiming this as "today's" blog post. I have had to roll back the time of the post to before midnight to get it to appear in the "right" box on the archive calendar. But that's what staying up late gets you!

No related content found.

Leave a Reply

Your email address will not be published. Required fields are marked *