Tuesday, March 22, 2005

VeryBizarre.Net

So, for the first time I'm knee deep in VB6 and VB.Net amongst others (lots of everything on my current project) and anxiously awaiting my copy of Working Effectively with Legacy Code (Michael Feathers, Addison Wesley).

Fixed a possible null reference access yesterday by changing:
If connection.State = ConnectionState.Open Then
connection.Close()
End If

to:
If Not connection Is Nothing And connection.State = ConnectionState.Open Then
connection.Close()
End If

At least I thought so, shows up that the And-operator in VB isn't short circuit...enter AndAlso:
If Not connection Is Nothing AndAlso connection.State = ConnectionState.Open Then
connection.Close()
End If

My next thought: "How do you do short circuit Or?" *drumroll* OrElse, but of course...what else...

Spend a few seconds Googling the history of this nasty language and found http://weblogs.asp.net/dneimke/archive/2003/08/13/23844.aspx, read it, had a laugh and showed it to my colleague whose immediate response to "TryHarder" is "How about CatchMeIfYouCan?".

0 Comments:

Post a Comment

<< Home