Once, I asked a coworker for a feature request. His service was outputting hashes and I wanted the original strings. His reply was that if I had an algorithm to reverse a hash --- all that this service stored and obviously impossible --- he'd implement my feature. My suggestion was that he record an input-to-hash mapping and just reverse that. The feature was checked in that day; perspective makes all the difference. My next feature request was that he set up a signal handler to catch signal nine, as he had attached cleanup routines to several other signals. I guess he spent the rest of the day trying to figure out why it wasn't working.


And I guess that's the point: for many things there is an obvious solution, for some things there is no solution, and wisdom is knowing the difference. The problem is second-guessing things that cannot occur, especially when you guess wrong. One of our field agents, Paul, recently had a run in with murderous #9; he writes,

'We once bought some code from a large company who shall remain nameless. Security was the big issue, so a programmer came up with the not-so-bright idea of how to be sure that a small utility program would really exit and not somehow keep running.


"The usual way to end a program in C is to simply perform an exit in the code.  If you are both paranoid and clueless, you can follow this programmer's example and replace all occurences of exit in your code with

kill( getpid(), 9 );

On the other hand, it took Andy quite a bit of time to come to terms with the inevitable end of all processes, or at least the exceptional end of some.

I work for a big utilities company in Australia. Recently, I went back to browse through some old code to determine the impact of small system change and found this absolute gem. We use the factory handler pattern throughout our system. This is an extract from one of the handler classes.

package process.handler;
public class ReconnectHandler extends HandlerBase {
 /** Handler class name */
 private static Class handlerClass;

static
 {
   try
   {
     handlerClass = Class.forName("process.handler.ReconnectHandler");
   }
   catch (ClassNotFoundException e)
   {
 CommonMessages.logExpansionException(e, "ReconnectHandler Class");  // This exception cannot occur;
   }
 }
 ...
}

It's a pity handlerClass is also an unused global variable.
In a later note, he realized: "To add insult to injury. I went back into the cvs repository to find out who did it. It was a piece of code I wrote, fresh out of university, when I first joined."
 
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!