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

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube