MichaelC,
Really? How is being forced to use a VB6 feature an advantage?
Because this "feature" has an equivalent in C#, where static classes
have the same advantage?
As you now have learned to know that extension methods have to be
declared in a module in VB.NET, you might already know that extension
methods are declared in a static class in C#.
Technically, on CLR level, VB.NET's modules are almost the same as
static classes in C#. With both of them you cannot create instances.
The only, but very little important difference is that modules can't
have a private constructor (no matter, a one liner does solve that task
in a VB.NET module). Modules are simply a syntactical shortcut to
static classes, as you'll save the time of typing the "static" keyword
at any declaration of members.
In C#, static classes are commonly used for libraries (see System.Math,
e.g.). As they aren't "evil" in C#, why should the equivalent in
VB.NET bei "evil" at all?
In VB.NET, using a class having only shared members, is not the same
like a static class. Because of such a class instances may be created.
Even it might be not very interesting creating instances having no
usable members, it might not be the the intention of a developer of
such a class. At least the possibility to create instances seems not
to be clean and consistent, compared to static classes. For that, take
a module in VB.NET, and you'll have a clean "class" that cannot be
instantiated.
Last point: The assumption that VB.NET developers cannot but running
into "bad" VB6 style goes too far. I do know lots of "young"
developers who started programming in .NET, in VB.NET, without ever
knowing of "bad" VB6 styles. And, for example, I myself have started
using OOP principles and architectural models in VB3, being happy to
find more and more OOP in VB4 and finally in VB5/6. Neither in VB.NET
nor in C# I am missing any "bad" "features" that many people, but never
all of them, might have been using in VB6 and earlier.
Harald M. Genauck
"VISUAL STUDIO one" -
http://www.visualstudio1.de
"ABOUT Visual Basic" -
http://www.aboutvb.de