Reply to post: Many mistakes, probably

You've seen things people wouldn't believe – so tell us your programming horrors

BinkyTheMagicPaperclip Silver badge

Many mistakes, probably

I'll own up to two, but coding is not my main activity, so it could be worse

1) Never, ever, *ever* do your own date calculations

Years ago I wrote a web log file processor in Python, to track visitors, and do everything webalyser did (except for using cookies) at much less cost, plus various custom stuff. To check log files it took the current date, processed a file, then added 24 hours to the time and looked for that file.

This worked fine for about four months, and then it all stopped working. Co-incidentally, this was the Monday after the clocks went back.. Add 24 hours, still Saturday! Add 24 hours, still Saturday...! Add fix to add 25.5 hours, and use the date functions properly to go to the next day in future.

Don't get me started on people who think they can handle time zones without a library : clue, you probably can't, and yes some places have half hour time zones.

2) Don't believe the specification

Doing nameless things with MAPI and Exchange, my code worked for months and then bombed. Various debugging revealed that it was failing to find a field, hit the exception handler, and fell over because this case wasn't correctly handled. It wasn't handled because the SDK (written by Microsoft), communicating with Exchange (written by Microsoft) informed me that this parameter was 'mandatory' and would always be there. Which it was, until suddenly it wasn't. (I think it was PR_something_RTF - rich text is supposed to be included, but only plain text was in rare instances - a handful of messages out of thousands).

I'd handled errors on every other field - except that one, because it would 'always be there'

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon