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

  • Xamarin.Forms 5 Preview Ships Ahead of .NET 6 Transition to MAUI

    Microsoft shipped a pre-release version of Xamarin.Forms 5 ahead of a planned transition to MAUI, which will take over beginning with the release of .NET 6 in November 2021.

  • ML.NET Improves Object Detection

    Microsoft improved the object detection capabilities of its ML.NET machine learning framework for .NET developers, adding the ability to train custom models with Model Builder in Visual Studio.

  • More Improvements for VS Code's New Python Language Server

    Microsoft announced more improvements for the new Python language server for Visual Studio Code, Pylance, specializing in rich type information.

  • Death of the Dev Machine?

    Here's a takeaway from this week's Ignite 2020 event: An advanced Azure cloud portends the death of the traditional, high-powered dev machine packed with computing, memory and storage components.

  • COVID-19 Is Ignite 2020's Elephant in the Room: 'Frankly, It Sucks'

    As in all things of our new reality, there was no escaping the drastic changes in routine caused by the COVID-19 pandemic during Microsoft's big Ignite 2020 developer/IT pro conference, this week shifted to an online-only event after drawing tens of thousands of in-person attendees in years past.

Upcoming Events