A Y2.1K Problem

| No Comments

Precision Blogging has an interesting entry today about commenting your code. I tried to add a comment of my own, but his comments server was down. My comment would have been, more or less, this:

Real programmers don't comment. If it was hard to write, it should be hard to understand.

Seriously, though... back in 1988 I was writing some code for a time/date display where we were only allowed two digits for the year (still in the era before anybody cared about Y2K). We didn't care about the first two digits anyway, until I found out that although 2000 would be a leap year, 2100 would NOT be, which would throw all the day-of-month and day-of-week calculations off. So I added a comment something like this:

/* Under the Rule of 100, the year 2100 is not a leap year. Under the Rule of 400, the year 2000 is. This code is written to work in the latter case and fail in the former. If this aircraft is still flying in the year 2100, I will personally return from the dead to fix the code. */

The Government reviewer was amused; my boss, somewhat less so.

Leave a comment

Pages

Powered by Movable Type 4.34-en

About this Entry

This page contains a single entry by Chris published on January 21, 2004 6:57 PM.

Can A Voice Be Considered A Deadly Weapon? was the previous entry in this blog.

Gotta Spend Money To Make Money, Oui? is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.