Cool .NET Tips and Tricks #20
By Dr. Dexter Dotnetsky
Dr. Dotnetsky

Howdy! Dotnetsky here -- back again after an extended secret mission that I can't talk about. (I was in Phoenix, I hopped a train like in the "old days" and hoboed my way to the Native American Church to find out what is it in peyote that causes such unusual effects, and how it can be used in Martini recipes. I also wanted to find out if it can improve your coding skills. I haven't written a single line of code since I was there, so I guess it has some promise -- but I'll keep you posted.)

But now I'm back, so look out. The rant is coming! Ya know, I never dreamed I'd become so popular. One of those "blogger" people even has a list of all my rants on his blog:

And this, even after I clearly explained that Blogs Suck. Did a lot better job of finding all the little boogers than those two nerds here at ever did! They keep changing the damned wallpaper on this site to the point where I can't even find anything anymore! Well, nevermind. The whole thing about any site or product is "shelf shout". Sometimes the content doesn't matter as much as the presentation, if it really looks nice.

Visual Studio.NET 2005 and Shelf-Shout

VS.NET 2005, even in BETA 2, has acquired some real shelf shout. The installation is snazzy and eclectic - it has all "socially correct" non - Caucasian people showing up on those revolving ad panes during the install, smiling and looking satisfied while you are waiting for your 11,297 new Registry entries to be added (not to mention the 6,987 Registry Entries that were still left there, like screaming little orphans on the beach after the tsunami, when you uninstalled your previous copy of VS.NET 2005 BETA 1...)

But it definitely has Shelf Shout - not just the install -- the features in the IDE too -- the Help, Debugger Visualizations, and much more. A nice job. ASP.NET 2.0 is one area that has some major improvements in how the IDE works, round-trip HTML in design and code view, a built-in Cassini webserver, loads of new controls, and much more. And it also has a new Framework to go with it that supposedly has twice as many classes as Framework 1.1. Now, that's a real kick in the head-- its gonna keep me busier than a one-armed paperhanger.

Dot Net 2.0 Book Tsunami headin' yer way....

Dr. Dotnetsky has a pile of 50 some-odd books on DotNet 1.1. Might as well chuck 'em all, cause I'm gonna need a whole buncha new ones for Dot Net 2.0. However, I can see some real business opportunities here for a totally new kind of "book". Now here's the deal:

You have a web site that presents a browsable, searchable class library browser for the entire .NET Framework 2.0. You can type in a search phrase about what you need to do, and you get back a list of links to content and articles, ordered by relevance. As you drill down, you are presented with descriptions and even code snippets that are contributed by the authors and member-readers, as well as links to the MSDN-2 url rewrite scheme of searching by namespace, e.g. :


If it were advertiser-supported, you wouldn't need a publisher and you wouldn't need to sell any books. Just let people come on site and read the content! Makes total sense to me. But then, heh! -- what do I know? I m just a dumb geek. Hey, where's the Gyro Sauce?


Nigel Shaw, who happens to be a highly experienced developer, wrote a piece about VB.NET vs. C# on, but it's a "different" article. Rather than focusing on the languages, it focuses on the cultural history and differences representing the evolution of each language and the developers behind it. Actually, one of the more thought-provoking pieces I've read. Dr. Dotnetsky doesn't totally agree with Mr. Shaw, but does agree conceptually (for those who are students of DotNetskyHistory, here's a link to my last rant about VB.NET vs C# which is more technical in nature.)

Not to be daunted, our own Peter Bromberg apparently has seen fit to chime in on his own "UnBlog" about VB.NET. ("Un" blog my butt! Looks like a fewkin' blog to me!) As one would expect, the majority response to Shaw's excellent piece was from apparently "affronted" VB developers, many of whom possess below room-temperature IQ's and who cannot even spell, who attacked him personally and showed (unsurprisingly) how utterly crude they can really be, all the while completely missing the obvious major point of Shaw's article which really has little to do with "putting down" VB.NET and VB.NET developers and more about explaining how, historically and culturally, things came to pass in his expert view.

The fact of the matter "according to Dexter" is that there are a few really really good OOP - oriented developers in .NET who prefer to write code in Visual Basic .Net. And, almost without exception, they do so with Option Strict and Option Explicit turned on, and make every possible attempt to avoid the dependence on the Microsoft.VisualBasic namespace. They dont't write CType(mystring, Integer) or CInt(mystring) when they can write Convert.ToInt32(mystring). They don't write CType(thisObject, thatType) when they can write DirectCast(thisObject, thatType). And, they know the difference, and why you should do it. And, they use carefully constructed Try / Catch / Finally blocks, not "on error goto" which is probably the most horrible coding construct ever conceived by man on this planet, at least since Barney Rubble invented the electronic ignition system some 45,000 years ago.

Dr. Dotnetsky would venture to say, moreover, that the majority of these "Expert VB.NET coders" are actually using VB.Net because they are book authors, technical presenters or teachers and they know they can make more money because if they put out their content in VB.NET instead of C#, there will be a bigger audience and more money. So be it. Microsoft created VB.NET because of marketing and money too, not because we needed a new .NET language. If we did, all of ASP.NET and the Enterprise Library wouldn't have been written solely in C#. These "expert VB.Netters" are people who are usually perfectly capable of doing all their coding in C#, and choose not to in order to be able to pay the mortgage. But, alas, they are a small minority. And let me just say one more little thing. When I need total, utter speed for intensive math and arrays, like when I am doing a managed audio codec implementation for my RTP Stack, I want to use pointer arithmetic. No way I am gonna do that with "wee bee".net.

By the way, in Visual Studio.Net 2005, Option Strict is still "Off" by default. Believe it or not, the following utterly ridiculous code will compile under "VeeBee DotNet" without a whimper:

Public Class BoyAmIDim
Public Function TestMeOut(ByVal strTest As String) As Boolean
If (IsNumeric(strTest)) Then
Return 5
Return -23
End If
End Function
End Class

Don't laugh, Kiddies. Dr. Dotnetsky has actually seen code like the above and had to fix it. They were returning integers from a method whose return value was clearly marked Boolean. It's not that the integer values were wrong - that in itself proves the kind of boo-boos you can commit-- so much as the fact that in the Common Type System, a Boolean can only be either true or false, not "a number". Of course, in C# you have to write type-safe code, or it simply won't compile. There is no false luxury of "Option Strict" off, and you better believe that's the way it should be!

Scott Hanselman says, "Set VB6.0=Nothing". Dr. Dotnetsky says, "Set VB.NET = VB.NOT". And Dr. Dotnetsky agrees with Nigel Shaw about the 80 - 20 rule. The majority of VB.NET coders are lazy, unwilling to learn, and a bunch of insecure crybabies. Their mean IQ is shockingly lower than that of C# developers. (Hey, if you wrote out the word "Dim" 100 times a day, your IQ would decline too). If they were mature, forward thinking developers, they would have taken the time and gone through the pain of "RTFM" and would now be coding in C#, in which unlikely case of course, this whole debacle would be moot. Above all, they certainly wouldn't be posting the kind of vulgar comment spam you see at the bottom of Mr. Shaw's fine article, whether you agree with it or not.

Bottom line? If you really want high performance managed code, use C++, and forget about the morons involved in the debate, most of whom are vulgar, opinionated, and haven't a clue on either side. "Third Floor: Debugger Visualizers, Generics, Iterators and SQL Server Service Broker..." The VB.NET crowd is really seeing a different Windows Wizard dialog, because they have, by choice, stuck themselves with a driver that can't be upgraded:

Surely, these "Vee-Bee" developers, who think their poop smells like Chardonnay, will help usher in an era of industry-wide innovation, huh? Anders Hejlsberg and his team are , I am sure, just sitting by the phone, waiting on pins and needles, to hear their expert advice.

Note: Since this was originally posted, there have been a number of comments about in various places where it appears to miss the mark. Let me be a bit more specific about the issue as I see it: VB.NET is an "almost" first class member of the .NET language family. I say "almost" because there are certain language capabilities that it does not have. I'm not talking about things like

With xyz
End With

-- Those are language features, not language capabilities. Being able to do pointer array referencing is a capability. Being able to overload operators, and so on. You can write perfectly fine CLS-Compliant code in VB.NET, provided you turn on Option Explicit and Option Strict, and REMOVE all references to namespaces with "VisualBasic" in their names. But, 90%+ of VB.NET programmers will not do this. THAT'S THE ISSUE, PERIOD! It's a cultural, NOT a language issue! You can debate which language is better based on features until your face turns blue, you still didn't get it! I've even seen one blog post where somebody tweaked IL code to the point where they could state that VB.NET was 9 clock ticks faster than C# for some particular operation, and if it is, that's WONDERFUL, but it's NOT THE ISSUE! The issue is people being encouraged, through propagation of culture, to write BAD CODE, get away with it, and not know the difference! Can I make it any plainer?

Yerba Mate Department

On a new note, while in Phoenix with my Indian friends, Dr. Dotnetsky tried Yerba Mate for the first time. This is the infusion made from a relative of the small Holly tree leaves and is the national drink of Argentina, Uruguay and Paraguay. Millions of primarily Spanish speaking people in South and Latin America drink up to 20 cups of Yerba Mate daily. It has no known side effects, give you a wonderful energy high (it has "Mateine", a close relative of caffeine, but without the jittery side effects) and is loaded with vitamins and antioxidants. You can buy this in health food stores, it has a kind of woodsy smell and looks a bit like low - grade homegrown weed, but it has a very pleasant taste when mixed with a bit of sugar that can grow on you. Recommended. (No, I haven't tried mixing it with Vodka yet). In South America they drink it from a gourd and sip it from a metal straw called a Bombilla that has a built-in filter at the bottom to prevent the fine leaves and stems from coming into your mouth. It has no known aphrodisiac effects, other than being an excellent excuse to sit down inside with a beautiful woman under the pretense of "do you wanna see my bombilla?".

Well, there will be more, but since I am just getting back into gear, wait a bit and I'll be back with the fury of a Wormhole between two Braneworlds. Cheers!

Dr. Dexter Dotnetsky is the alter-ego of the forums, where he often pitches in to help answer particularly difficult questions and make snide comments. Dr. Dotnetsky holds no certifications, and does not have a resume. Always the consummate gentleman, Dr. Dotnetsky can be reached at  Dr. Dotnetsky's motto: "If we were all meant to get along, there would be no people who wait for all the groceries to be rung up before starting to look for their damn checkbook."