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

  • 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.

  • At Build 2026, Microsoft Sets Up Windows as an OS for AI Agents

    Microsoft's Build 2026 Windows developer announcements point to a broader platform strategy for agentic AI, spanning terminal workflows, local models, app-building skills, Cloud PCs and operating system-level containment.

Subscribe on YouTube