Another

coding

story

(This one is kind of technical, sorry.) We're working on this computer game called Terra Nova, where you run around outside in powered battle armor with your squadmates beating people up. One guy on the team is a junior programmer, who is a fine guy and an okay coder, but whose coding style isn't all that 'mature', as we say in the business -- the code often isn't very elegant or robust. Anyway, he's working on this system for displaying data about your powered battle armor. There's a little 3-digit LED that shows the suit's temperature, and he's putting the temperature into string form for displaying there. So his code looks something like this: temp_to_str (int temp) { char str[4]; sprintf (str, "%d", temp); and so forth. I tell him, "Hey, this is no good, because if the temperature ever goes over 1000 (or under -100), you'll overflow your string and the game will just totally crash without warning." He says, "Oh yeah, okay, whatever, I'll fix it." So I look back at the code a couple days later, to make sure that he's fixed it, and he has indeed changed the code. It now looks like this: temp_to_str (int temp) { char str[4]; if (temp <= -100 || temp >= 1000) fprintf (stderr, "WARNING: PROGRAM IS ABOUT TO CRASH!

"); sprintf (str, "%d", temp);