Peter Korsten used to work with a truly brilliant and exceptional individual. Before leaving for greener pastures and better pay, one of his former co-workers left an indelible mark on their system via his rather unique approach to programming.

The Great 8 Report

One of these artifacts was the "8" report which consisted of the following SQL query: 

  select 8 from some_table

Ok, so it didn't really select  from a table named "some_table", but the resulting output was a list of 8's, formatted into an email and sent across the organization, including the CEO. Peter figures that the original author hadn't pressed the 'Shift' key hard enough and had intended to do this instead: 

  select * from some_table

However, what Peter can't figure out is how this report has been sent out for several years an nobody has ever complained about receiving a single-column report consisting solely of the number 8.

4,000 Records Should Be Enough for Anyone

Another gem left behind was a C program that imported a text file and performed various operations on the data. Unfortunately, he didn't allocate the memory for the records dynamically and instead set the limit of the number of possible records to 4,000. As a result, it was little surprise when the data file hit 4,001 records and the program crashed hard with a segmentaiton violation.

Rather than fix the problem the right way, the Peter's former co-worker opted to increase the maximum number of records 10-fold to 40,000 and also added a "feature" to make sure that if the first program crashed, the one following it would be invoked.

What Could Possibly Go Wrong?

Finally, what tale of a programmer who did things in their own unique way be complete without their own take on searching an array? Sure, opting to do a binary search on an array of strings is a perfectly reasonable approach, but I can't think this is the best solution.

bool binsearch (char* sr[20000],char* imsi,int lo,int hi)
{
 int low, high, test, found1;

 low = lo;
 high = hi;
 test = 0;

 found1 = -1;

 if (low > high)
  return false;
 else
 {
  test = ((low + high) / 2);

  if (strcmp(sr[test],imsi) == 0 )
   return true;
  else if (atof(imsi) > atof(sr[test]))
   binsearch(sr,imsi,test+1,high);
  else
   binsearch(sr,imsi,low,test-1);
 } //end while loop
}

 

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!