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

  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

  • What's New for Python, Java in Visual Studio Code

    Microsoft announced March 2024 updates to its Python and Java extensions for Visual Studio Code, the open source-based, cross-platform code editor that has repeatedly been named the No. 1 tool in major development surveys.

Subscribe on YouTube