The Fencepost Problem
If there’s anything I’ve noticed that plagues many less-experienced programmers, it’s what I refer to as the fencepost problem (or fencepost error, if you will). The problem can be most succinctly summed up using this thought exercise: Imagine a fence that is 100 meters long. A fencepost is needed every 10 meters. How many fenceposts are needed?
The answer is, of course, 11. See the image:
Notice that there are 10 sections of fence, but there are 11 fenceposts. This error is a more specific case of the infamous off-by-one error that occurs in coding in general.
Why am I bringing this up? Because major software writers get this wrong all the time. Consider the following picture:
This screenshot is from Doodle.com, supposedly the most popular scheduling application in the world. Let us assume that I actually did check off 6PM as shown in the picture. Do you know how much free time that denotes?
The problem is that 6PM is a fencepost, and time availability is “sections of fence,” ranges of time. A single fencepost sticking in the ground doesn’t denote any length; a second post is needed. The problem is that the visualization on Doodle has switched the fences and the fenceposts. Notice how the hours are marked by blocks, and time between the hours is denoted by a white border. The result: I have to color in two blocks to indicate that I’m available for one hour, and coloring in one block means squat.
But wait, there’s more! Now, imagine for a moment that one person’s availability was from 5PM to 7PM, and another’s was from 7PM to 9PM. What would that visualization look like?
Argh. Now try to imagine for a moment that I’m trying to schedule a meeting with 12 people (and um, is longer than 59 seconds), and they all enter their crazy, ridiculous schedules into Doodle, and I have to deal with sorting out overlaps that aren’t overlaps because they start and end at the same hour, but look like overlaps and … ugh, are you listening, Doodle?
Let’s move on to whenisgood.net:
As a writer of scheduling software, this irks me. The engineers can’t seem to let go of the fact that the hour markings have to take up more room than the time between the hour markings. Luckily enough for me, Google Calendar does not succumb to this problem.
I guess that’s why those engineers get paid the big bucks.