Writing Robust Programs
Software failures range from annoyances to serious losses, and their consequences grow in proportion to the importance of the task the software is given.
A Small Annoyance, a Large Loss
Most people who use computers have run into a program that stops responding or closes without warning. Often the cost is small: a few minutes of frustration and a window to reopen. This article is about the other end of that range, the failures that cost far more than an annoyance. The aim is to build a habit of mind that will be useful whenever you write or rely on software.
What do you think happens?
Before reading on, think about a program you use every day. What is the most serious thing that could go wrong if it failed without warning?
Reveal answer
There is no single correct answer. The point of the exercise is to notice that the answer depends on what the program is used for, and that the same kind of failure can cost very different amounts depending on that use.
The source organizes failures along a spectrum. A failing program can be an annoyance, but the consequences grow in proportion to the importance of the task the software is given.
As you read the examples that follow, keep one question in mind: at what point in the chain from a programmer's decision to a physical outcome did things go wrong? That question separates a useful account of a failure from a simple list of disasters.
Picturing the Range of Consequences
The source describes a spectrum of consequences. At the mild end, a failing program is an annoyance. On a personal computer, a failure can still cause lost work or lost money. When a computer is given more important tasks, the consequences of its failure become proportionately more serious, and in the most severe cases they include loss of life.
The diagram shows the escalation the source describes. Each step up the ladder corresponds to a more important job given to the computer. The levels are a teaching device drawn from the source's own examples, not a formal classification of software failures.
When a Units Mismatch Breaks a Mission
In September 1999, the Mars Climate Orbiter burned up in the Martian atmosphere. The source explains the cause in a single sentence: data expressed in English units of measurement, such as feet and pounds, was entered into a computer program designed to use metric units, such as centimeters and grams.
Notice what did not go wrong. Nothing in the program was simply wrong in the sense of a crashing line of code. The program did what it was built to do. The numbers it received simply did not mean what it assumed they meant. A value is only as meaningful as the unit attached to it, and when two parts of a system disagree about that unit, the disagreement is invisible until the physical outcome arrives.
The diagram shows two sides of the mismatch. The data was written in one system and the program read it as if it were written in the other. The failure lies in the gap between those two assumptions. This is why the case is listed among problems caused by incorrect assumptions as well as by unit mismatches.
What do you think happens?
The program receives a number from another system. What is the one piece of information that could prevent this failure?
Reveal answer
The unit the number is expressed in
The source shows that the program was designed for metric units and received English units. Knowing and agreeing on the unit is what separates a correct value from a misread one.
When a Wrong Assumption Breaks a Landing
A few months after the Orbiter was lost, the Mars Polar Lander probably crashed. Its software was supposed to detect the bump when the spacecraft touched down and then turn off the engines. The source reports that deploying the landing gear might have jarred the spacecraft enough to activate that detection step early.
The program then turned off the engines while the spacecraft was still high above the ground. The source notes that the unpowered craft would have fallen to the surface. The program's logic assumed that a single triggering signal always meant touchdown. That assumption held in the situation the designers expected and failed in the situation that actually occurred.
Read the sequence from top to bottom. The landing gear was not itself the error. The error was that the detection step accepted a signal that did not reliably mean what the software assumed it meant. Each later step faithfully carried out the earlier assumption.
Tracing the Chain From Decision to Outcome
Following one failure from start to finish
Use the chain-of-consequences question to analyze the Mars Climate Orbiter loss. At what point did things go wrong?
- 1Identify the data source
The data was expressed in English units such as feet and pounds.
- 2Identify the consumer
The program was designed to use metric units such as centimeters and grams.
- 3Locate the gap
The program received the numbers and did not have them meaning what it assumed. The gap is between the two sides' assumptions about units, not a crashing line of code.
- 4Follow the consequence
The mismatch led to the Orbiter burning up in the Martian atmosphere in September 1999.
The failure began at the point where a value crossed from one system to another without its unit being agreed on. The consequence was the loss of the spacecraft.
Apply the same question to the Mars Polar Lander. Write down the earliest point in the chain where a wrong assumption entered, and the point where it became a physical outcome.
Hints
- Start with the signal that the detection step received.
- Ask what the program assumed that signal meant.
- The physical outcome is the engine shutdown while the spacecraft was still high above the ground.
Why Stakes Rise With Task Importance
The source points out that the cases get more serious as the work assigned to the computer gets more important. It names three domains where failures directly affect people's health, money, or safety: medical devices, financial systems, and aerospace applications. The two Mars cases belong to aerospace.
- Northeast Blackout of 2003: the source says computer software error contributed to one of the largest power outages in history.
- 2006 Airbus A380 delay: the source reports software incompatibility problems, at a cost it estimates may have reached billions of dollars.
- 2007 Los Angeles International Airport: a software problem grounded thousands of planes.
- May 6, 2010: a flaw in an automatic trading program apparently resulted in a 1000-point drop in the Dow Jones Industrial Average.
- 1990 AT&T long-distance disruption: a newly loaded computer program proved to contain a bug, disrupting service throughout the United States.
Together these cases show that the risk is not limited to a single decade or a single kind of machine. Robust checking matters in every domain where software does work that people depend on.
A Failure Without a Faulty Line
It is natural to assume that a software failure means a programmer wrote an incorrect program. The Mars Climate Orbiter case shows that this is not always so. The program in that case did what it was built to do. The failure came from a gap between the specification, the assumptions made, and the real physical system.
This is why the source asks you to look at the whole chain from a programmer's decision to a physical outcome. Robustness is a property of the connections between a program, its assumptions, and the world it acts on, not only of the code inside it.
Mistakes That Hide Failures
Common mistake Assuming that a failure always means a crash or a bug in one line
What it looks likeThe Mars Climate Orbiter program ran without error and still led to the loss of the spacecraft.
Why it failsThe source states that nothing in the program was simply wrong in the sense of a crashing line of code. The failure lived in the gap between assumptions.
Do this insteadTrace the chain from the decision to the physical outcome and look for mismatched assumptions at each handoff.
Common mistake Treating a single signal as a reliable meaning
What it looks likeThe Mars Polar Lander detection step accepted a jolt from the landing gear as a touchdown signal.
Why it failsThe source reports that the detection step might have been activated early by the deployment jolt. One signal was trusted to mean one thing.
Do this insteadAsk what else could produce the same signal and whether the program can distinguish those cases.
Common mistake Treating small inconsistencies as harmless because the program runs
Common mistake Judging a risk only by how it feels on a personal computer
Why it failsThe source shows that consequences grow in proportion to the importance of the task. A failure that costs a few minutes on one machine may cost far more on another.
Do this insteadEstimate the stakes from the importance of the task the software performs, not from the experience of the user at the keyboard.
Practicing the Chain Question
Choose one of the failures in this article other than the Mars Climate Orbiter. Write a short account of the chain from the programmer's decision to the physical outcome. Name the single point where the assumption was violated, and say what information would have been needed to catch it.
Hints
- Use the source sentence that describes the cause before you write your answer.
- Be specific about which assumption was wrong, such as the unit, the meaning of a signal, or the expected conditions.
- A good answer names the handoff between two parts of the system, not just the final disaster.
Key Takeaways on Robust Programs
- 1Software failures range from annoyances to serious losses, and their consequences grow in proportion to the importance of the task the software is given.
- 2The Mars Climate Orbiter was lost when English-unit data reached a metric program, and the failure lay in the gap between the two sides' assumptions.
- 3The Mars Polar Lander's detection step treated an unexpected signal as touchdown, shutting off engines while the spacecraft was still high above the ground.
- 4A failure is not always caused by an incorrect program; it can come from gaps between the specification, assumptions, and the physical system.
At a glance
- Software failures range from annoyances to serious losses, and their consequences grow with the importance of the task.
- A units mismatch can cause failure even when the program runs without error, because the numbers do not mean what the program assumes.
- A wrong assumption about a signal can cause a program to act on a condition that is not actually present.
- A failure is not always an incorrect program; robustness depends on the connections between specification, assumptions, and the real world.