2017-03-16

Logic Errors, Edge Conditions, and Politics

We software engineers spend a lot of time -- too much, we think, but usually too little -- trying to ferret out two things that make our programs blow up. Politicians should learn something from our experience.

Logic Errors

One of those program problems is logic errors. I can easily illustrate what that is. Suppose you're writing a program for a robot that is able to move around within a building. A small snippet of code might be something like this:

if( Doorway.Door.IsOpen ) {
    Doorway.Door.Open();
}
Doorway.Traverse();


Do you see the logic error? There's one, tiny thing missing: the word NOT. It makes no sense to open the door if it's already open. We want to open the door if it's closed. The program should look more like this:

if( NOT Doorway.Door.IsOpen ) {
    Doorway.Door.Open();
}
Doorway.Traverse();


That's what logic errors are all about. This is the easiest kind of program bug to find and fix. Most of the time, we fix them before our programs get out of the lab.

Edge Conditions

What's harder to fix is unhandled edge conditions.

Visualize all of the conditions that a program can encounter as a the surface of a two-dimensional sheet of paper. The vast bulk of these conditions are somewhere in the interior of the sheet, surrounded by other conditions. Those are the "usual" conditions, and they're what we write the program to handle. But the sheet has edges, conditions that weren't uppermost in our minds as we wrote the program.

If the robot in the first story inhabited a building in which the doors are mostly open, the programmer might forget that if block above. The program to handle doorways might be just this:

Doorway.Traverse();

But then the robot, trying to follow its simple-minded instructions in its simple-minded way is found with its "chest" against a door, stupidly pushing and pushing and pushing, but getting nowhere because the door is closed.

The closed door is an edge condition. Edge conditions are why if blocks appear in code. We put in at least one if block for every edge condition we can think of.

Politics

I'm guessing you probably aren't a software engineer. But maybe you're a voter. Maybe you're even a politician. If so, read on.

We software engineers write programs that tell dumb computers what to do and how to do it. Politicians do something very similar, but they're programming whole societies, not idiot computers. Yet their programs are often dumber than my worst effort. They make logic errors and they ignore edge conditions.

Here's just one example of a logic error: Writing a law to fix a problem that does not exist. Voter identification laws are in this category. There has never been enough documented voter fraud to justify these laws. Oh, yes, you can correctly say that we ought not to let people vote if they are not eligible to vote. Indeed! But how often do ineligible people attempt to vote? Where are your statistics? How do they justify the expense and effort of what these laws require? Mostly they don't. And I'm not even talking about the real purpose of the laws: preventing certain types of eligible voters from voting. These laws spend my tax dollars, trying to fix a problem that pretty much doesn't exist.

Then there are edge conditions. Let's think for a moment about the bathroom bills that are becoming so popular in some of the redder states, including here in Texas. They want to force people to use the public restroom that corresponds to the gender on their birth certificate. They think that this is a simple matter. Everybody is either male or female, right?  And birth certificates are never wrong, right?

Pathologist Gerald Callahan's book, Between XX and XY: Intersexuality and the Myth of Two Sexes, points out that more than 65,000 children are born every year without an obvious sex. The doctors who deliver them do not know whether they are boys or girls. Some children are born as apparent girls but naturally become boys at puberty. Some people don't have precisely two sex chromosomes in their cells -- they aren't XX or XY. Some are XXY or XXXY or XXXXY or only X. Which restroom should those folks use? Those people represent unhandled edge conditions in the societal program that we call "The Law".

And then there are the transgender people, the ones that are actually targeted by these laws. I have seen a photograph of a person who was born female and went through the sexual reassignment process. She/he bulked up and became the very image of a huge, imposing, menacing Black dude with tattoos. Imagine him/her obeying the law and using the ladies' room in a restaurant. Can you imagine police being called to deal with the Black man who has the nerve to enter the ladies' room? I can. Would you perhaps be more comfortable if he/she simply used the restroom that's more appropriate to his/her apparent gender? I would.  This person represents an edge condition that is not handled well by the proposed Texas bathroom bill -- yet she/he is the very target of that bill.

You might be tempted to conclude that the legislators who are in the process of enacting this bill are intentionally trying to crash the system. That's what it would look like if this law were a computer program.