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

  • Creating Business Applications Using Blazor

    Expert Blazor programmer Michael Washington' will present an upcoming developer education session on building high-performance business applications using Blazor, focusing on core concepts, integration with .NET, and best practices for development.

  • GitHub Celebrates Microsoft's 50th by 'Vibe Coding with Copilot'

    GitHub chose Microsoft's 50th anniversary to highlight a bevy of Copilot enhancements that further the practice of "vibe coding," where AI does all the drudgery according to human supervision.

  • AI Coding Assistants Encroach on Copilot's Special GitHub Relationship

    Microsoft had a great thing going when it had GitHub Copilot all to itself in Visual Studio and Visual Studio Code thanks to its ownership of GitHub, but that's eroding.

  • VS Code v1.99 Is All About Copilot Chat AI, Including Agent Mode

    Agent Mode provides an autonomous editing experience where Copilot plans and executes tasks to fulfill requests. It determines relevant files, applies code changes, suggests terminal commands, and iterates to resolve issues, all while keeping users in control to review and confirm actions.

  • Windows Community Toolkit v8.2 Adds Native AOT Support

    Microsoft shipped Windows Community Toolkit v8.2, an incremental update to the open-source collection of helper functions and other resources designed to simplify the development of Windows applications. The main new feature is support for native ahead-of-time (AOT) compilation.

Subscribe on YouTube