Hilton Giesenow's Jumbled Mind

Thursday, August 12, 2004

Boolean Operator Short-circuiting.

I was showing someone a code snippet today that included an AndAlso statement and they were quite surprised to discover what it was. It got me thinking back to when I discovered AndAlso and OrElse short circuiting. I remember reading a posting at the time where someone asked why it wasn't the default behaviour and the more I think about it the more I agree.

They way these statements work, for example is as follows. If you have a string variable strName and you want to determine if it is (a) Not Null and (b) not = "Bob". The following statement will fail:

If Not IsDBNull(strName) And strName <> "Bob" Then

The reason for this is that BOTH checks are evaluated and if the variable is in fact null an exception will occur on the last part. What we really want is: Check if the variable is not null THEN ALSO (i.e. if the first part evaluates to True) check that it is not equal to "Bob". This would need two separate If statements to accomplish otherwise. The AndAlso statement accomplishes this and OrElse performs a similar operation versus the Else statement. However, I am hard-pressed to think of many common situations when you would definitely want to execute both statements. Perhaps if one is calling one's own Boolean function it would make sense. Otherwise, I definitely think these should be the defaults. First of all, if you think about it "AndALSO" makes more sense in english (as does OrELSE). In addition, the current behaviour is more likely to trip a beginner up and it leads to unneccesary code.

Any opinions on this? Anyone agree / disagree?

Thursday, August 05, 2004


I stumbled upon this tool the other day, and it is fantastic. WebDeploy is a creation by Matt Hawley that allows you to quickly and easily deploy an ASP.NET web app. It has a bunch of kewl features, definitely check it out if you work in ASP.NET.

Tuesday, August 03, 2004

Wired Mag: Porn Blogs Manipulate Google

And guess what just came in to my SharpReader feed? Apparently this porn-blog thing is quite common.

BTW, I recently installed SharpReader. It is an RSS/Atom Aggregator, which means that it pulls from multiple rss feeds, and it polls them every hour. Very kewl. I've now got loads of info coming in constantly 8-).

Paris Hilton Blog

Har Har. Somebody just informed me that there is a site of some sort relating to Paris Hilton's infamous video, and that it is also a *.blogspot address (See Paris Hilton Video). Apparently, to find my blog, don't type Hilton and Blogspot into Google!

Followup: We have Mailmarshal filtering on, and it is blocking the site, so I can't even check it out!

Web Service Exception in Visual Studio 2003

I've been working quite a bit with XML Web Services lately, and every now and then I get the following exception:

"Only one WebServiceBinding attribute may be specified on type..."

A search on Google returned few results, only one of which was helpful. It suggested restarting Visual Studio. This works, but I was curious as to what was happening. I discovered that Visual Studio.Net stores a cached version of whatever Web Application is currently open, and that this cache can become corrupted. The location of this cache can be found in Tools - Options - Projects - Web Settings, under the "Offline Projects" section. To fix this problem, browse to the folder and delete the specific cache for the web services project, then close and re-open the solution from within V.S. Alternatively, as the gotdotnet posting suggests, just close and re-open the entire IDE. I've also heard of other problems occurring from this cache becoming corrupted, but there does not seem to be an actual way to rebuild it directly from within Visual Studio.

Does anybody know of a way to do this?