Blog Home  Home Feed your aggregator (RSS 2.0)  
What did you learn today? - Thursday, March 11, 2004
Phil Denoncourt's Technology Rants
 
 Thursday, March 11, 2004

When I first started programming Windows applications back in the early 90's, I used to read all of the KB articles that Microsoft put out.  This kept me relatively well informed of some of the more advanced features in their products.  It also made me aware of their limitations.  Over time, there were too many articles and too little time to keep up with them, so I've since stopped trying. 

Now the KB articles can be retrieved using RSS!  If you go to http://www.kbalertz.com/allKbs.aspx drill into the category you're interested in and subscribe using the link on the XML icon. This is a great way to keep track of developments out of Microsoft.

Thursday, March 11, 2004 5:05:00 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]    | 
Fastest way to split strings by Phil Denoncourt
I've written quite a few HTML scrapers (reading an HTML page, and parsing out information contained in it) and the biggest part of these programs are the string manipulation.  I usually break the HTML page up into string arrays and run through the array looking for keywords.  In .NET, you can break strings up using the .Split method of a string object or you can use Regular expressions.  I find regular expressions powerful, but cryptic to write and maintain, so I use the split method more often than not.  Darren Niemke has benchmarked different methods of spliting strings in .NET
Thursday, March 11, 2004 10:10:00 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]    | 
 Wednesday, March 10, 2004
AndAlso / OrElse by Phil Denoncourt

I've been a VB developer since version 2.0.  Everytime a new version of VB comes out, I skim the “What's New” section of the documentation and then begin using it.

Something that has escaped my scrutiny is two new operators that were added in VB.NET: AndAlso / OrElse

These are related to the And / Or operators, but work a little differently.  Consider the following routine that checks to see if data was returned from a method:

Dim obj As DataSet

obj = GetMeADataSet()

If Not (obj Is Nothing) Then

    If obj.Tables.Count > 0 Then

        If obj.Tables(0).Rows.cout > 0 Then

            'Check out the data

        End If

     End If

End If

It would easier to write the statement as:

Dim obj As DataSet

obj = GetMeADataSet()

If Not (obj Is Nothing) And obj.Tables.Count > 0 And obj.Tables(0).Rows.Count > 0 Then

    'Check out the data

End If

Unfortunately, this statement will fail if obj is nothing or there are no tables in the dataset.  Why?   Because VB will execute all three parts of the if statement, resolve them to boolean values and then perform the boolean math with the AND operator.

The AndAlso operator, has a “short circuiting mechanism“.  As soon as it encounters a false value, it know that the IF statement will not be true, so it either goes to the ELSE section or leaves the if statement.  The opposite is true for the OrElse operator.  As soon as a true condition is found, VB knows that the final result will be true, so it jumps into the IF statement.

So the statement can be rewritten as follow and it will not fail:

 Dim obj As DataSet

obj = GetMeADataSet()

If Not (obj Is Nothing) AndAlso obj.Tables.Count > 0 Andalso obj.Tables(0).Rows.Count > 0 Then

    'Check out the data

End If

Frankly, I don't know why anyone would continue to use the And / Or operators anymore. 

Wednesday, March 10, 2004 12:14:00 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]    | 
The Start by phildenoncourt

I just got this application up, configured and running!  My hope is to add entries as I come across interesting tidbits about .NET during the day

So if you've come across this page randomly, let me tell you about myself.  Married with kids(5) for 14 years.  I'm currently employed as a Senior Software Engineer at SunGard BSR in Waltham MA writing ASP.NET apps in VB.NET.

I've been a computer enthusiast(geek) for over 20 years, and have worked in the industry as a programmer in some capacity for the past 15 years.  Right now, I'm focused on .NET and the upcoming Whidbey release.  I run the New England C# user group, and present at other area user groups from time to time.  If you're further interested in my professional bio, my resume is posted at www.denoncourtassociates.com

I appreciate feedback on what I post here – is it helpful? 

-Updates: Changed number of kids and URL

Wednesday, March 10, 2004 10:51:00 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]    | 
Copyright © 2008 Phil Denoncourt III. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: