VB. NET as a serious language
Almost every VB.NET programmer has been plagued with
passionate pleas to “Learn C# and save your career!” So some folks might be
wondering if I am some kind of pied piper leading them further down the “wrong
road” with this tutorial. They might be asking, “Why a Design patterns
tutorial in VB.NET?” After all, design patterns are an advanced topic for
serious enterprise developers, right? Should not this topic be discussed in
the domain of C#, C++ or Java? So even though you have a history in VB and
lots of experience in it why not just give in to the pleas and go with C# as a
serious developer?
Well, because the concept of C# as a more serious language
is an absolute fallacy. Most of the literature I have read comes to a point in
the language-choice when the author boils it down to the issue of comfort
level. VB6 versus Visual C++ was a big issue because VB6 was not object
oriented. However, in the .NET incarnation, VB has come of age and is fully
object oriented and so VB versus C# is a non-issue.
Why the stigma?
One of the problems with Visual Basic is the “BASIC” part of
the name (and it does not help either that the B stands for Beginners!). There
is also the long partial OO legacy. Then there is the supposed carryover of undesirable,
unstructured features from VB6 (like weak type checking). Well, I think
Microsoft can solve this problem easily. Name the thing Visual B or Visual B++
or B# or something else that distinguishes it; anything to prevent people from
having to go to group therapy because their career is built on something
“BASIC.” Now granted, Microsoft has not helped with a few regressive moves
like allowing programmers to use win-forms without declaring them, harking back
to VB6 days. However, complaining about that sort of thing is like saying you
do not want to come and enjoy a sunny Jamaican vacation because you are married
and Jamaican women are too beautiful. Well, enjoy the vacation and resist the
temptation. Simple… right? J
V for verbosity?
I am a verbose person, VB.NET is a VerBose
language. Quite frankly, that is why I like it. I am someone who uses
variable names like “ForeignCurrencyConversionRate.” You have to remember that
with a simple press of CTL-spacebar, you can bring up your variable names. Putting
your classes into namespaces also helps to quickly access your classes. Therefore,
long variable names and class names are not that big a deal. Sure it makes it
easier to reverse engineer when you build to IL, but then there is obfuscation
software available to help you prevent this; so even that is not a big deal.
VB.NET versus the “serious alternative” C#
VB.NET was made for implementing AND demonstrating design
patterns due to its very explicit nature. With C# you know what is happening,
but because of its leaning towards silence you can miss a trick or two. The
beauty of VB.NET for showing how design patterns work is its very verbosity. At
every turn it screams “This is what is happening in this statement” and so it
is somewhat self documenting. You do not have to worry, like you have to in
C#, whether that little colon thingy has interface implementation or class
inheritance behind it.
What others think about VB.NET versus the “serious
alternative” C#
Finally, I want to provide a comment from an author. Here
is the comment from Francesco Balena on the use of C# versus VB.NET:
Francesco Balena - Programming Microsoft Visual Basic
.NET version 2003
“ … .NET moves most of the
functionality from the language to the .NET Framework itself. For example, the
.NET Framework includes classes for opening, reading, and writing text and
binary files, so there is no point in having this functionality embedded in
programming languages. … All .NET languages can use these classes, and
therefore all languages have the same capabilities in creating applications
with a rich user interface, without having to resort to low-level, advanced
techniques such as subclassing. … C# is actually a great language that takes
the best ideas from other languages, such as C++ and Java. But the truth is that
C# and Visual Basic .NET are roughly equivalent… The two languages have the
same potential, so you are free to choose the one that makes you more
productive. Execution speed is also equivalent for all practical purposes,
because the C# and Visual Basic compilers generate more or less the same code.”
Conclusion:
Why spend so much time defending VB and quoting authors who
do not think that VB.NET is inferior to C#? Well, writing about
design-patterns in a 2nd class language would be a bit like building a mansion
in the ghetto or a plaza in quicksand. That is why I have made such an effort
to assure you that VB.NET is very much 1st class. If you are very
good at VB.NET, then you do not need to learn some other language before taking
your O-O skills to the next level. Convinced yet?
Resources
Balena, Francesco. Programming Microsoft Visual Basic 2003.
Core Reference, Microsoft Press, 2004. ISBN: 0735620598
Duel, Michael. Non-software examples of software design
patterns. Object Magazine, Jul 97, p54.
Fischer, Tom, John Slater, Peter Stronquist and Chaur G. Wu.
Professional Design Patterns in VB.NET: Building Adaptable Applications.
Apress, 2003. ISBN: 1590592743
Gamma, Erich and Helm, Richard and Johnson, Ralph and
Vlissides. Design Patterns, Elements of Reusable Object-Oriented Software.
Addison Wesley, 1994. ISBN 0201633612
Holub, Allen. Holub on Patterns: Learning Design Patterns by
Looking at Code. Apress, 2004. ISBN: 159059388x
Kuchana, Partha. Software Architecture Design Patterns in
Java. AuerBach, 2004. ISBN: 0849321425
Tabor, Bob. 2400-video series, Learn Visual Studio.Net,
2003.