Erician Hall of Convoluted Shame

Introduction

Over the years, I have developed a fearsome reputation for making things much more complicated than they need to be. Now, if I was some creative type, some kind of angsty poet, this wouldn't be so bad. The problem is that I am a programmer -- and worse, a computer scientist (this is what they tell me, but I don't buy it either). Complexity is the bane of our existence. Complexity in the erician doing everything backwards sense, not the big-O notation sense, of course.

There are few things in the world that draws more strongly against a programmer' soul than this vague, pseudo-mathematical notion of elegance, solving problems in the most beautifully simple way possible. Elegance, the thing which makes our tickles our sense of the sublime, that feeling, oh this is beautiful it almost pains me to see it. And elegance, precisely everything which I am not about.

Mind you, I do desire elegance, I do ache after it the way any programmer with the slightest self consciousness about his code might. But actually being elegant is an altogether different story.

This hall of shame is meant to collect some for the most stunning exhibits of erician convoluted stupidity. My knack for making things way harder than they need to be. Let these creatures here be a cautionary tale, a warning, a word to the wise. Don't code like me. *.

(*) Except for the refactoring. Refactor obsessively, it's good for you.

The collection

Reverse and trim (12 dec 2005 - Haskell)

Given a string like xIDxOTHER_STUFF, i was trying to strip off the x's and the OTHER_STUFF and extract ID. My technique?
   0. start               : xIDxOTHER_STUFF
   1. tail                :  IDxOTHER_STUFF
   2. reverse             :  FFUTS_REHTOxDI
   3. dropWhile (/= 'x')  :             xDI
   4. tail                :              DI
   5. reverse             :              ID
 
The problem? What happens if OTHER_STUFF has an 'x' in it? (for example EtreAux). Everything from step 3 down is wrong. The new solution?
  
   0. start              : xIDxOTHER_STUFF
   1. tail               :  IDxOTHER_STUFF
   2. takeWhile (/= 'x') :  ID
  
Not only more correct, but cleaner and simpler to boot.

The binary search (2001 - Java)

This was a very long time ago, and I hardly remember it. But there was this subsubsubtask I needed to get done for the final project in my undergrad program. For some reason or another, I needed to extract three or four lines from a sorted text file that I was reading into memory. Oh simple, I thought! They taught us how to do that kind of thing well; I'll just cook up a simple binary search. It took me a whole to code this all up because I had to worry about array indices or something like ridiculously simple like that, but at last, I got my simple binary search done, not too many lines of Java at that. I mentioned this to my supervisor, that yeah, I sorta got delayed by this subsubsubtask and explained my solution.

She looked at me quizically: "Why didn't you just use grep?"


2006-06-06 to 2006-06-06