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

  • Mastering AI Development and Building AI Apps with GitHub Copilot

    Two Microsoft experts explain how GitHub Copilot is evolving from a coding assistant into a broader platform for building, customizing and testing AI-powered developer workflows.

  • VS Code 1.123 Adds Agent Session Sync, 1M Context Windows

    Microsoft released Visual Studio Code 1.123 on June 3, adding agent-focused features, larger model context support, integrated browser updates and a new delay for some automatic extension updates.

  • Copilot Billing Shock Hits Developers

    Developer complaints about GitHub Copilot's new usage-based billing model have centered on unexpectedly rapid AI credit consumption, and neither GitHub nor Microsoft has responded directly to the backlash, though they have previously published guidance to lessen model usage costs.

  • Hands On with GitHub Copilot App Technical Preview: Turning a Blazor Issue into a PR

    GitHub's brand-new Copilot desktop app, in technical preview, handled a small Blazor issue from planning through pull request creation, but the hands-on test also showed why developers still need to verify agent work in the running app before merging.

Subscribe on YouTube