Andreas had a pretty good idea of what he was getting in to. The job posting subtly included the duty of "helping to straighten up the software environment." The technical screening consisted of three questions: what is HTML, what is PHP, and what is SQL. And the interviewer subtly mentioned that the previous programmer was a "great guy, but had a few quirks." Yes, Andreas knew he was walking into a nicely presented system that's more messed-up than a building flattened with a 2-ton bomb ... shortly after being flattened with a 5-ton bomb. But that's OK; it would be a challenge.

Having worked there for over a year, Andreas mentioned that his tenure was a lot like his subscription to The Daily WTF. Each day (weekends and holidays excluded), he'd be introduced to yet another astonishing perversion in Information Technology. Actually, he still works there now, but since he's completely reverse engineered, re-designed, gutted, and re-implemented the system (or, "helped to straighten it up"), he's back to relying on this publication as his source of daily WTF's.

One of Andreas' first experiences at this company was running into the previous programmer. Being the great guy that he was, he agreed to come in and help out with fixing critical issues with the system. Since a "critical issue" popped up on the first day (and actually, the second, third, fourth, etc.), Andreas got an opportunity to see how the previous guy did his thing. It involved Remote Desktop Client (to logon to the production server) and Dreamweaver (installed on the production server) and a careful editing of live code files and pages. Sound familiar? Andreas was right in the middle of a Developmestuction Environment.

Like all other Developmestuction Environments, the code files and pages had random prefixes (new_, new2_, prod_, live_) and suffixes (.old, .bak, .old.bak, .old.bak.bak). But what made this one especially obnoxious was the complete lack of subdirectories. The root folder housed over 400 of files, most belonging to completely different modules. Actually, there was one subfolder: it contained all the code and pages for the previous programmer's World of Warcraft clan website.

As you might imagine, this was just the tip of the iceberg. The database was "dynamically designed," meaning that column names and datatypes were "abstracted" out to the code, leaving hundreds of database tables, each with VARCHAR(50) columns named things like f1, f2, f3, ..., f51. The file system would often crash (oh yes, file systems can crash) as a result of having several million customer-uploaded files kept in the same folder. And the previous programmer actually got "in trouble" for trying to sell this proprietary software on eBay.

All this said, you might imagine how difficult it is to present a good, representative example from this system. But I think I've found one in the code that Andreas sent me. Now, it may seem a bit anti-climactic, but pay close attention to the subtleties in the (non-generated) code ...

<script type="text/javascript"> <!--

function onCheck(id)
{
  checkedValues = document.selecter.checkedValues;
  checkedBox = document.selecter["check_"+id];
  
  if (!checkedBox.checked)
    checkedValues.value = 
           eval("checkedValues.value.replace(/" +id + ',' + "/g,'')");
  else
    checkedValues.value+=(id+',');
}
      
function submit()
{
  document.location.href = 'insert.php?chosen=' + 
     document.selecter.checkedValues.value;
  return false;
}


//--></script>

<form id="selecter" name="selecter">
  <input type="hidden" id="checkedValues" name="checkedValues" />
  <input class="button" type="button" value="Submit" onclick="submit()" />

  <input id="check_4273844" onclick="onCheck('4273844')" type="checkbox"
         name="check_4273844" value="ON" />
  ...
  <input id="check_4273843" onclick="onCheck('4273843')" type="checkbox"
         name="check_4273843" value="ON" />
  ...
  <input id="check_4273842" onclick="onCheck('4273842')" type="checkbox" 
         name="check_4273842" value="ON" />
  ...
</form>
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!