Are you 100% sure that your code works?

1005During private pilot flight training every student must complete a cross-country flight at night over a distance of at least 100 nautical miles total. A student of mine came to this point in his training and we planned a cross-country flight that met the distance requirements. The night was clear and very dark as we departed for our first stop: Carroll County Regional airport in Westminster, Maryland. When I say the night was dark, I mean there was no moonlight. See, flying at night comes with a constant anxiety that something will go wrong and you will be forced to land. During the day you can look down and see dozens of fields that would be perfect, but at night, unless there is a full moon, you can’t see the trees and power lines that would get in your way. Airplane engines are very simple and robust. In fact, I don’t know anybody who has suffered an engine failure in flight, yet we train for it constantly. So night flying makes me a bit anxious and it makes the students very anxious. The other problem at night is with navigation. I don’t let my students use the GPS (except when that is the point of the lesson) so the navigation is handled with a map and a compass.

On this night the student was off to a great start; he was headed in the right direction and was picking out roads and towns to help keep track of our position. As we crossed over some unlit rural areas he let the airplane drift slightly. There was a strong steady wind from the south pushing our course north of where the student expected to be. He was using the heading he had computed, but did not correct it to account for the wind. As we got closer to where the airport was supposed to be we began looking for the beacon. Many airports have a large rotating light that flashes white and green to let you know it’s an airport. (Yes, this is like a lighthouse for planes.) Almost immediately he spotted a beacon about ten miles away and declared, “There it is.” I knew we were not looking at the beacon for Carroll County, but that this was in fact York airport in front of us so I asked, “How sure are you?” “100%!” he replied. I said, “Ok” and decided to make this into a learning opportunity rather than just telling him where we were. As we approached the airport the student was 100% sure of where he was, so he didn’t look at other landmarks. If he had, he would have noticed that the airport was south of the town, when it should have been north of the town. He would have noticed that the highways were all going the wrong direction, along with some other key navigation features. I decided to monitor the frequency at York on our 2nd radio and let him take it all the way in.

Just before landing he announced on the radio that he was on final for runway 34. A minute later our landing lights illuminated the runway number, 35, and he noticed the discrepancy. He said that the chart must have gotten it wrong. When we are 100% sure of something, all other evidence is presumed to be wrong. After we landed he noticed more things out of place and realized what had happened. We changed our flight plan right there so it would still meet the requirements and continued on our way.

 

When we are 100% sure of something, all other evidence is presumed to be wrong.

553

The lesson here is that you should never be more than 99% sure of something. Leave room for doubt and ask yourself questions about the other evidence in front of you. When you allow yourself to be 100% sure you are allowing yourself to stop thinking. I apply this rule to programming as well. If the code works in every tested situation, it is very tempting to think that it will work in some almost identical alternate situation. 99% of the time it will, but you should carefully test alternates even if they seem unreasonable. Never stop thinking and second guessing your work. This will help you to find more bugs before launch and produce better code. This is one of the reasons why unit testing is so powerful. It is easy to believe that unchanged code would continue working, but it doesn’t always work out that way.

Launching code without being 100% sure about it

If you can’t be 100% sure of anything, how can you ever push the code out? At some point you need to accept the 99% and push the code out. When you are 99% sure, assume that there really is a bug in your new code and try to find it. See if you can come up with one more situation to test. If you are 99% sure and you just can’t come up with another bug then the code is ready.

As a flight instructor, I love getting students into situations that they will never forget. After that flight I began telling all of my students to never be more than 99% sure of anything. I feel that this idea has improved their flying by forcing them to keep thinking the whole time.

Leave a Reply

Your email address will not be published. Required fields are marked *