Developer Fail: A Few Precious Seconds

Ever since Brendan's department had gained ownership of OPSVUE, an enterprise-level application written in Visual Basic .NET used to manage user access to the various homegrown apps, years of unfulfilled enhancement requests and ignored bug fixes had come pouring in.

An issue reported by one user, Alice, stood out.

A power-user, Alice had gained notoriety for the tickets she filed complaining that some screens were taking one to two seconds longer to load than expected. Eager to make a good impression, Brendan responded to her tickets as best he could and explained that the delays might be the result of her working in a remote office.

No Good Deed...
This scenario repeated a number of times until Brendan was finally called into his manager's office.

"Brendan," his manager began in a stern tone. "Alice from West Coast Operations thinks that you have somehow tampered with her access to OPSVUE in retaliation for her filing so many tickets."

Caught off guard, Brendan almost fell out of his seat.

Brendan's manager nodded and continued: "Believe me, I'm on your side, but this squeaky wheel is going to only get louder unless you can give her those seconds back."

Back at his desk, Brendan wracked his brain -- even though he'd fixed a number of things, he didn't have a good idea of how everything fit together. Determined, he meticulously traced through the functions and eventually found a clue:

If (UserData.UserName.Length > 0) Then
  'Now check if the user exists in the User table...
  Dim myUsers = From user In db.Users _
                Where user.PayrollNumber = _
                  rgxExpGXXX.Replace( _
                  ServiceSecurityContext.Current.WindowsIdentity.Name, "")

  If myUsers.Count = 0 Then
    bNewUser = True
    For Each rec In myUsers
      If (UserData.UserName = rec.Name) Then
        If (rec.Active = False) Then
          rec.Active = True
        End If
        UserData.UserId = rec.Id
        rec.Active = False
      End If
    'If we get to here and the User Id is still zero then...
    If (UserData.UserId = 0) Then
      bNewUser = True
    End If
  End If

  If (bNewUser = True) Then
    Dim newRecord = New CommonDal.User With { _
      .PayrollNumber = Environment.UserName, .Name = _
        UserData.UserName, .Active = True}
  End If
End If

Zero Logic
Upon inspection, Brendan found that the "Users" table had swelled to 15,000 rows -- most of which were duplicates of Alice's User ID. The reason? Turned out, years ago, Alice assisted the original developers in testing OPSVUE and as a result, they included logic to detect her special User ID: 0.

Because taking out the "zero logic" would be painful and time-consuming, Brendan took the easy approach: He changed her User ID to a non-zero, non-special number. Granted, this revoked Alice's power-user abilities, but her screens loaded up much faster.

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


  • GitHub Copilot for Azure Gets Preview Glitches

    This reporter, recently accepted to preview GitHub Copilot for Azure, has thus far found the tool to be, well, glitchy.

  • New .NET 9 Templates for Blazor Hybrid, .NET MAUI

    Microsoft's fifth preview of .NET 9 nods at AI development while also introducing new templates for some of the more popular project types, including Blazor Hybrid and .NET MAUI.

  • What's Next for ASP.NET Core and Blazor

    Since its inception as an intriguing experiment in leveraging WebAssembly to enable dynamic web development with C#, Blazor has evolved into a mature, fully featured framework. Integral to the ASP.NET Core ecosystem, Blazor offers developers a unique combination of server-side rendering and rich client-side interactivity.

  • Nearest Centroid Classification for Numeric Data Using C#

    Here's a complete end-to-end demo of what Dr. James McCaffrey of Microsoft Research says is arguably the simplest possible classification technique.

  • .NET MAUI in VS Code Goes GA

    Visual Studio Code's .NET MAUI workload, which evolves the former Xamarin.Forms mobile-centric framework by adding support for creating desktop applications, has reached general availability.

Subscribe on YouTube