September 8th, 2003

Illuminati

Not Bad

Very few things strike more fear into me than the statement that something's "Not Bad".

"You should give this a listen, it's not bad."
"You should go see this film, it's not bad."
"You should waste 2 hours of your time on this, it's not bad."

I don't want things that are 'not bad', not bad isn't a compliment, it's a statement of dull mediocrity. I want great things, exciting things, things that take me to strange far-away places and show me sights that I haven't seen before. If the most that something is able to inspire you to in recommendation is "not bad" then I really have better things to do with my time. I demand that something be at least 'good' before I spend my time on it. On the other hand, if you find something of indescribable awfulness, then I may well be tempted. But it'd better be pretty bloody awful.
Illuminati

Testing Testing

Another good thing from Extreme Programming - testing suites. The idea is that you create a test suite for each program _before_ you create it. Your program is working only when it passes all of the tests. You add tests as you spot possible ones during the coding and re-run the tests whenever you change the code.

I was handed an old COBOL program, written in he COBOL-74 standard (as in 1973) and told to bring it up to date in COBOL-85 (and yes, there is a COBOL 2000, but we're not getting that for another year or two). I did a bit of rewriting before I realised that while I was pretty sure that my changes so far hadn't changed functionality, I couldn't be 100% sure. So I wrote a test suite to call the program with 15 different combinations of data (it's a fairly simple program) and made sure that the tests all passed ok. Then, whenever I refactored some code after that, I'd recompile and re-test. If the test suite passed, that meant that my new code hadn't done anything seriously different. I added a few tests as I went along, when my changes added new branches into the code.

Because I knew that my changes definitely worked, I felt far less worried about the effects my code changes were having. I could happily move whole chunks around, provided I re-ran the tests straight afterwards to spot any errors that had crept in. A 150-line program swiftly became a 30 line program - and I know that it's right, because it does exactly the same as the old program did with the same data.

I'll definitely be doing more of that in the future.