xkcd: Unreachable State – been there, done that…

As a developer, I was so tempted to put messages like this in the parts of the code that should never execute. I did a couple of times, although never this clever. I’m not up on the latest programming languages, but I imagine that it is still possible to have these places of despair. These ‘black holes’ of code where you should never go but if you do, you will never recover.

A variable that should only EVER be one of four values, will someday not be. An hours of the day field that should NEVER be more than 23 (or 24 depending on how/why you are counting) someday will be. If you check and act on those values, you will have a part of the code that happens when those assumptions are false.

Defaulting to do-nothing doesn’t help is not an option either. If you are doing stuff in the checks that later code on depends on, you can’t ignore that.

Once I worked for a company where the lead developer was a massive Vikings (US football) fan and one of the other developers was a Packer fan. I had a design where each of the these black holes would simply call the same routine that would display a message about the Vikings. The Packer fan was going to write it. But the development team stayed (too) professional and wouldn’t do it. When I commented that this code should NEVER execute and asked why not do it (the effort was tiny), they hemmed and hawed. They were not convinced that that “couldn’t possibly happen”, you know, would actually happen. They knew that black holes happen and impossible code execution happens.





Related Posts

Latest Posts



Find Me On

Privacy Policy

John Bredesen

Copyright 2023 ©