Saturday 4 June 2016

Nothing beats fixing a 12 year old bug!

Pretty much for as long as I can remember, Sourcery has exhibited a strange problem where it will just stop in the middle of compiling a project. I tried a number of times to find the problem but it was so intermittent that I kind of left it alone.

When I started Sourcery it was on a StrongArm RiscPC. I then migrated to VirtualRPC first on Windows XP and then on Ubuntu.

More recently I have been running RISC OS 5 on RPCEmu - the latest version of this is so good - as well and this is when the problem really started to show itself and I was finally able to track it down. Partly because I had to and partly because looking at the code again after a few years let me see it in a different way.

The problem? When firing off a task to do the compilation I was assuming that when the task handle that came back was 0 then I didn't have to do anything because it had failed. In fact, on newer hardware the compilation stage was just so fast that it was finishing immediately.

The previous intermittent failures were due to the very occasional  task finishing very quickly.

The lesson? Read the PRM more closely.

I wish when I had started coding on RISC OS the concept and support for TDD had been something I was aware of. Any Java coding I do now is always TDD. Both the safety net of coming back and making changes at a later time and knowing you haven't broken anything, and the way it makes you think when coding do lead to much better software.

That's not to say it's a silver bullet. You have to be disciplined enough to do it and to keep the code coverage high.