Until nothing – The Daily WTF

José received some head-scratching VB .Net UI code.

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

While the pattern does not exist, if the pattern exists, exit the loop. I assume this is meant to be a busy loop, waiting for some UI element to be ready. Because busy loops are always the best way to wait.

But even with a busy loop, If is a conundrum – why exit the loop early, when the loop condition will terminate itself? Did they just not understand how loops work?

The last thing to note is the variable naming conventions. frmMyForm is a common convention in WinForms programming, a bit of Hungarian notation to tell you what a UI element actually is. But what is it *supposedly* to be F there? Do they do… double Hungarian? Is he telling us that this is a form? Or maybe they want to tell us that it is a class field? Or maybe the developer said “F my life”?

We would all be better off if this code were nothing.

[Advertisement]

BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Find out how!

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *