DevDisasters

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
  Else
    For Each rec In myUsers
      If (UserData.UserName = rec.Name) Then
        If (rec.Active = False) Then
          rec.Active = True
          db.SubmitChanges()
        End If
        UserData.UserId = rec.Id
      Else
        rec.Active = False
        db.SubmitChanges()
      End If
    Next
    '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}
    db.Users.InsertOnSubmit(newRecord)
    db.SubmitChanges()
  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

Featured

  • Kubernetes for Developers

    Microsoft's Dan Wahlin previews his introductory "Kubernetes for Developers" session at Visual Studio Live! San Diego 2026, explaining how developers can get past the Kubernetes learning curve by starting locally, mastering Pods first, and using Services to make containerized applications reliably accessible.

  • VS Code Keeps Eye on Costs in v1.126 Update

    Visual Studio Code 1.126 adds session-level Copilot cost information, continuing Microsoft's recent focus on helping developers monitor and manage usage-based GitHub Copilot billing.

  • Open VSX 1.0.0 Puts Focus on Open Extension Registry for VS Code Ecosystem

    Eclipse Open VSX has reached 1.0.0, highlighting its role as a vendor-neutral registry for VS Code-compatible extensions.

  • Infragistics Puts MCP Toolchain at Center of Ultimate 26.1

    Infragistics Ultimate 26.1 introduces the Ignite UI Enterprise MCP toolchain for AI-assisted app development across Angular, React, Web Components and Blazor.

Subscribe on YouTube