Not too many of us are lucky enough to work side-by-side with a living Software Legend. Joe D is pretty close: he works with Scott, a self-proclaimed former Software Legend. You might wonder how exactly one becomes a former legend. Scott is always eager to explain: he was one of the world's best programmers back in the late 70's but has since been surpassed by all the extremely intelligent people who have entered the field lately. Okay, so it's not much of an explanation, but Scott swears by it.

Though he's not a current Software Legend, Scott is certainly legendary within his organization: he only writes code in C while everyone else uses Java because, as he claims, C is actually more object-oriented; he somehow manages to always schedule his vacations starting the day his code goes into production; and he has never been de-hired.

As you might imagine, it's difficult to find an example that appropriately illustrates Scott's work. But I think Joe found a good one. It's from an application that's used to process incoming credit card transaction files from several thousand different national merchants. Each file contains several hundred thousand transactions that need to be translated into their internal schema.

This particular function is responsible for determining if the transaction is from a "special" merchant and will require custom handling. Only two percent of merchants require this and these merchants are identified in the Special Merchants Configuration file ("spcmerch.cfg"). Every merchant has a four-digit merchant number, which this function inputs and returns a 0 if they are a special merchant or a 1 if they are not ...

int is_special_merchant(int merchnum) 
{
  size_t fln;
  char filedat[10000];
  FILE *file;
  int ab = 0;

  if ((file=fopen("spcmerch.cfg","r" )) == NULL ) return(1);
  fln = fread(&filedat, 10000, 1, file);

  if(fln == (size_t)0) return(1);
  fclose(file);
  if(filedat[merchnum] == 'Y') return(0);

  return(1);
}

And for completeness, here is the spcmerch.cfg file in its entirety. All twenty three bytes.

NNNNYNNNYNNYYNYYNNNNYNN

Why the former Software Legend thought that a twenty-three byte file would suffice when the code reads in 10,000 is a mystery. The fact that this random-result providing function is still in production is also a mystery. But the fact that this is bug is compensated for by several other equally-buggy and somehow-working functions -- now that's legendary.