Today I got to be a hero. The story of Codethulu, let me continue it:
By now I've spent over a week looking at this abominable code, all the time with a (non-fictious) deadline hanging over me*. Not only is the logic incredibly convoluted, as I've previously mentioned, but I've unavoidably noticed some pretty grave bugs and ticking bombs as well. This is where those of you familiar with the concept "Schrödingbug" are holding your breath.
Sure enough, fifteen minutes after I got to work today the director of finances was screaming hellfire about a problem that was much more severe** than the one I've been working on, and with a much shorter deadline. Now, because of vacations and my previous week of facing this monster, I was the one with the most experience dealing with the code in question, so I was called in immediately. My first hurdle was the few crisis modifications I had made and which I had tested in production (in cooperation with the project owner) but which was never put in production, which could have messed something up (remember the database connections going all over the place). Fortunately, we were quick to dismiss that possibility, and soon after the possibility of the new (non-working) features being the cause also followed. I still got to order my former*** boss, now acting boss-of-my-boss to roll back and take backups of the database, just in case.
When I got to work today, I enlisted our most senior programmer to pair program with me, both to spread the message that pair programming is good and to increase the bus number of the code in question****. In addition, our skills and focus areas are quite dissimilar and my intention was to exploit this. Now our task had changed and we had to throw all caution to the wind because there was no time, yet screwing up any further was not an option (but quite possible).
Unfortunately I can't go into much detail about the problem itself, but I can tell you that the code is incredibly slow. Our fallback, undo as much as we could, redo with the rolled back version and make some calls telling angry people who get paid to only think about money to forget about the money, would probably not make the deadline (a couple of days). And this was using lots of computers, including high-grade servers, to share the work. By the end of today we started a rewritten single-threaded batch application on a musty old developer pc***** that would chug through the entire dataset in a couple of hours. One of the things we did different from the original code was we didn't generate an image just to write it to file on a network share (overwriting the same identical file if it already existed, which was most of the time), only to read it back in right afterwards in order to use it.
Even more fun stuff happened. Our initial issue description was something like "the sequence is wrong," which neither of us knew what meant (of course), but it eventually lead us to reverse-engineer some weird custom barcode format. We did this just before a crisis-status-meeting where we impressed people with the ability to manually check parity bits and count in binary enough to buy more debugging information.
This new debugging information led us even further into the bowels of Codethulu, but suddenly everything fell into place in my mind. That moment when you suddenly emerge from the muddy disconnectedness and reach enlightenment is truly a great rush, which even now I'm riding on high as a house.
Just then the director of finance came to check in on us, and I shouted something like "The duplicates! The panel does not have a dispatch class! It is only used once! They were all fighting for the maximum!" at her. Kudos to her for managing to tolerate this gibberish and the sight of a fat geek dancing in front of her despite her own despair. Her only reply was "Great work! You shall receive an ice-cream for this," before she left without any further questions.
At this point, my pair and I were working so well together that communicating understanding was completely effortless. Sometimes we even both controlled the peripherals at the same time (allowing us to partake in refreshments without breaking our stride.) We were both in a state of high-quality flow that lasted for several hours.
Tomorrow I get to tell our director of finances that her invoicing system has support for playing music.
* Fortunately I'm safe in the knowledge that missing it wouldn't be my fault, but it would still have some non-negligible direct consequences for my employer's finances. The kind that shows up on graphs as unfortunate bumps.
** The kind that would prevent the graph from ever being made out of concern for people with heart conditions.
*** He was the boss of the development department but got sick of us maintaining our production environment. So he grabbed some practically minded developers and the DBAs and made a new department, leaving us to do development and system maintenance in peace. May he live long and prosper, and the force be with him.
**** I have no intention of being left alone with it ever again.
***** The kind with four different IDEs, antivirus and a constantly re-indexing email inbox from hell, all fighting for the same meager amount of resources.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.