Herfried said:
That's not a criterion for me. I see OO as a valuable tool, but I cannot
see any advantages of object-orientation in this particular case over a
procedural approach.
It's all about clarity as far as I'm concerned. When you use "Mid",
someone who doesn't know it's a "magical" VB function would be at a
loss to know what's going on. When you use String.Substring, it should
be obvious to anyone who knows *anything* about whatever language is
being used that you're calling a method on the string.
It's not a direct equivalent. For example, I use 'Mid' if I want to make
use of its special 'Nothing' reference handling capability.
Whereas I'd deal with that explicitly in code, as I believe that's
clearer - I suspect that far from everyone knows that special case.
(It's also not directly equivalent in terms of its "basing" of 1 rather
than 0. Again, as the rest of the .NET framework is essentially
0-based, that seems like an inconsistency to me. Yes, it's consistent
with VB6, but I'd hope to move towards a more .NET-centric code base
and away from a VB6-centric code base.)
Well, IIRC there are more developers on the world who are able to understand
'Mid' than 'String.Substring', I assume. Remember the popularity of VB6 --
all .NET languages together do not have such a huge number of users.
That will change, over time however. If you care more about readability
for VB6 developers than for other .NET developers, that's your choice
though. I think it's a reasonable objection for me to make at the same
time.
This may apply to any library. I agree with you that it's more likely that
'System.String' is implemented, but I'd consider a VB.NET implementation
without support of "Microsoft.VisualBasic.dll" as an imcomplete solution.
Well, it would still be a perfectly good ECMA library implementation.
There's a reason why it's *Microsoft*.VisualBasic...
I didn't take a look at these particular functions. Bugs can be everywhere.
The 'Like' operator of VB.NET has been flawed in VB.NET 7.*, for example.
It has been fixed in the current version. However, this operator could have
been widely used. I do not think that the overall quality of
"Microsoft.VisualBasic.dll" is lower than those of the .NET Framework class
library.
Maybe I happened to be unlucky then. It makes sense to me, however,
that the most used code tends to be the most reliable, because bugs are
more likely to get found in the wild and then fixed.
Well, sometimes I want this checks to be performed instead of putting them
into my code.
But they're already performed - in String.Substring! String.Substring
will check whether or not you've given it an invalid length, but if you
call Mid instead of Substring, the check gets made twice.
Jon