Saturday, December 06, 2008

Always check for off-by-one errors

I just ran into a pretty basic error using a Drupal module, one that lets you post repeating events. Of course I just saw taht there was a release update and just threw it on the CHANCES Family Centre site I was working on without re-testing it. It wasn't until one of the site administrators tried to create a weekly repeating event and fortunately went to check the results that she saw there was a problem -- subsequent instances of a new event were appearing one day early in the week. This is a classic off-by-one error that every programmer on earth has made more than once in their time. ("Wait, should that less than check be a less than or equal to?")

Unfortunately when something strange happens many users think that it's a problem with something thy did and they just don't understand this big complex piece of software and they never will get the hang of it and blah blah blah. And of course no user of a site should be expected to go to a module's drupal.org page and look at the open issues to see if anyone else is having the problem. My take-home from this is to be very wary of software module updates, and to not just trust something because it is an official release of a module.

Fortunately I have a good relationship with this particular client and was happy to put in a fix for them without too much trouble, instead of them just trying to muddle through posting events one day off intentionally, which is what users of commercial software that has a bug in it would have to do.

The classic double-edged sword of open source software development, a developer might be working on a bit of code to suit his own needs, and just not do enough diligent checks that he hasn't broken some other feature unintentionally. Drupal is finally getting into active automated testing, but this won't help you if you are using a module that isn't part of the mainstream set of actively-developed modules. Maybe all this is telling me to take up the mantle of contributing in more active and complete ways to keep the modules I want to use alive.

The slow hard but rewarding lesson of Open Source.

Labels: , , ,

By al - 3:58 p.m. |

    follow me on Twitter

    al's del.icio.us Links

    • www.flickr.com
      This is a Flickr badge showing public photos from dragonofsea. Make you own badge here.
    •  
    • (al)



    • Powered by Blogger