DevDisasters

The Spaghetti Code Incident

Henry was the TAXCALC king. But his coding skills were positively peasant-like.

By the sound of the tumult, you would've thought the fifth floor conference room was filled to capacity -- but actually, it was just Nicolas and a very angry developer named Henry.

"What business do you have not approving the production deployment?" Henry shouted as he pounded his palm on the long wooden table for emphasis.

This peer code review was going to be one for the books, Nicolas thought as he massaged his forehead.

"See? Here are the test cases I ran," Henry shrieked. "Management has already signed off on TAXCALC!"

Nicolas tried to interject, but it was of no use.

Henry rose and yelled, "You, sir, are an ignoramus!"

Then he huffed out of the room, upsetting his stack of test cases in the process.

Noodling Logic
The TAXCALC program was born as a FORTRAN program on the corporate financial services mainframe. The original developers were hackers and risk takers -- self-taught, self-governed, rewriting computer programming theory as they went.

By the time Nicolas joined the company, most of the original developers had already moved on, leaving Henry as the designated "TAXCALC king." As such, when it was decided that the time had come to move off of the mainframe, Henry was upgraded in the process.

He received a refresher in modern IT: classes in relational databases (unknown on the mainframe) and .NET programming in general. Henry took to C# quickly and used it to port TAXCALC to the 21st century.

Despite learning some new tricks, Henry's peculiar FORTRAN programming habits carried through to the new version of TAXCALC in functions like this:

static int STRTXG(int i0, int i1, int i2, int i3, int i4)
{
  switch (i0)
  {
    case -1:
      return STXTGH(i2);

    case 920:
      return SFFMAB(i1, i3);

    case 1222:
      return SHBGER(i1, i3);

    case 824:
      return SGXECB(i4);

    case 3:
      return STXGMB(i1) + STXKSB(i1) + STXNRB(i1);

    default:
      return 42;
  }
}

During his review, Nicolas found that TAXCALC was a single source file with hundreds of functions weaving in and out of each other. Magic numbers (or perhaps they were lucky numbers?) prevailed throughout. The only constant: Every function name was six characters long and began with the letter "s."

It was a surprise that the system worked for more than a couple of minutes, but for Henry, doing things this way was perfectly normal.

Mea Culpa
Henry apologized to Nicolas the next day for his reaction during the code review. He said his passion was to blame for his lack of common sense. In response, Henry was given a chance to take another shot at TAXCALC, and management kicked in the offer of some additional training specifically related to object-oriented programming.

A week after returning from his training course, Henry finished his changes and, based on how he greeted Nicolas, was eagerly awaiting his next code review.

"I made tons of improvements! Believe me, TAXCALC is better than ever!"

Nicolas politely nodded in acknowledgement, but internally, he was trying to quash his fears of what "better" really meant.

Just as Nicolas started to feel a bit of stomach acid tickle the back of his throat, Henry said: "Yeah, the instructor gave the class in Java -- what a great language! That's what the new TAXCALC is written in!"

Henry beamed ear to ear with pride. But it was Nicolas who was really delighted -- he wasn't involved in the Java peer code reviews.

About the Author

Mark Bowytz is a contributor to the popular Web site The Daily WTF. He has more than a decade of IT experience and is currently a systems analyst for PPG Industries.

comments powered by Disqus

Featured

  • Full Stack Hands-On Development with .NET

    In the fast-paced realm of modern software development, proficiency across a full stack of technologies is not just beneficial, it's essential. Microsoft has an entire stack of open source development components in its .NET platform (formerly known as .NET Core) that can be used to build an end-to-end set of applications.

  • .NET-Centric Uno Platform Debuts 'Single Project' for 9 Targets

    "We've reduced the complexity of project files and eliminated the need for explicit NuGet package references, separate project libraries, or 'shared' projects."

  • Creating Reactive Applications in .NET

    In modern applications, data is being retrieved in asynchronous, real-time streams, as traditional pull requests where the clients asks for data from the server are becoming a thing of the past.

  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

Subscribe on YouTube