CodeSOD: While Nothing

This post was originally published on this site

The Daily WTF

José received a bit of VB .Net UI code that left him scratching his head.

While IsNothing(Me.FfrmWait) If Not IsNothing(Me.FfrmWait) Then Exit While End If End While

While a form doesn’t exist, if the form does exist, break out of the loop. I suspect this was intended as a busy loop, waiting for some UI element to be ready. Because busy loops are always the best way to wait for things.

But even with the busy loop, the If is a puzzle- why break out of the loop early, when the loop condition is going to break itself? Did they just not understand how loops work?

Now, the last thing to note is the variable naming conventions. frmMyForm is a common convention in WinForms programming, a little bit of Hungarian notation to tell you what the UI element actually is. But what’s that *leading F there? Are they… doing

To read the full article click on the 'post' link at the top.