DevDisasters

Dev Disasters: Too Many Cooks

Dueling developers create an unappetizing code stew.

Fresh out of his corporate-approved .NET training, Jerrod was eager to dive straight into his first meaty assignment: support of the ReportsPlus application, the tool that the InfiniCorp business analysts relied on for their decision-making processes. Several .NET developers had mishandled maintenance of ReportsPlus in the past five years, leaving a few people unsure of how long a relatively inexperienced developer like Jerrod might last.

Quirky Code
If someone had asked Jerrod what he thought about the application after his first day of ownership, he'd have chuckled, calling its quirky coding puns like #define CARROT =^; and #define EIGHTY 256; at the top of every source file "cute" or "funny"!

Soon after, however, he reached the code used to generate random numbers in the application:

private int myRnd = Math.Abs(Guid.NewGuid().GetHashCode());

Jerrod thought this was strange because he was pretty sure that he could generate random integers using the Random function. Probably some undocumented way of making super-random numbers, he thought.

This reassured Jerrod until he hit the following code:

static public string GetPart()
{
  Thread.Sleep(10);
  Random r = new Random();

  int x = r.Next(16);

  switch (x)
  {
    case 10:
      return "a";
    case 11:
      return "b";
    case 12:
      return "c";
    case 13:
      return "d";
    case 14:
      return "e";
    case 15:
      return "f";
    default:
      return x.ToString();
  }
}

public string GenerateVal()
{
  return (GetPart() + GetPart() + GetPart() + GetPart() + GetPart() + 
  GetPart() + GetPart() + GetPart() + "-" + GetPart() + GetPart() + 
  GetPart() + GetPart() + "-" + GetPart() + GetPart() + GetPart() + 
  GetPart() + "-" + GetPart() + GetPart() + GetPart() + GetPart() + "-" + 
  GetPart() + GetPart() + GetPart() + GetPart() + GetPart() + GetPart() + 
  GetPart() + GetPart() + GetPart() + 
  GetPart() + GetPart() + GetPart());

Wait a second, Jerrod thought, GUIDs make random numbers and random numbers make GUIDs?! What was the developer thinking?!

Dueling Developers
Jerrod tracked down Jonathan, the previous ReportsPlus support guru, who was now a network analyst for another business unit on the other end of the corporate campus.

"Oh, yeah, this was way before your time. We called them the dueling developers," Jonathan explained. "David and Karl each had their own ideas on best practices and as a result, well, as the saying goes, 'Too many cooks spoil the broth'!"

"Why didn't you or any of your predecessors correct the code?" Jerrod wondered out loud, but all Jonathan did was laugh.

"Maaan, you really are green!" Jonathan exclaimed. "Hey, when your first month-end hits and you're up to your eyes in support tickets that last you through until the next month-end," he howled, "you won't have time to even think of refactoring ReportsPlus!"

Feeling queasy, Jerrod thanked Jonathan and meandered back to his desk wondering whether or not the class he took on Oracle databases back in college could translate into a resume bullet.

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

  • 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.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

  • What's New for Python, Java in Visual Studio Code

    Microsoft announced March 2024 updates to its Python and Java extensions for Visual Studio Code, the open source-based, cross-platform code editor that has repeatedly been named the No. 1 tool in major development surveys.

Subscribe on YouTube