Unlike the many million posts, comments and mindless shouting matches
preceeding this date, I will not delve into a discussion that one is
better than the other. Instead I’d like to talk about a situation
that I ran into today at work.
Although I’d known for some time that you could do this
using Microsoft.VisualBasic;
in your C# code, I never believed it to be a good idea. Today I ran
into a situation where I was debugging some code and sure enough I
found that code existing for the purpose of implementing the Visual
Basic IsNumeric() function. When I tried to explain to the developer
responsible for it’s existence why this was a bad idea, I found myself
unable to put together an arguement that was strong enough to rebut his
continual assertion that “It is just an assembly being referenced like
any other.” Nothing bothers me more than a person who can’t suggest a
change in code without having a strong supporting reason. Today I hated
me. Tonight I’m on a quest to bolster my quiver of arguments for the
next code review battle.
The question that needs answering (or at least a little attention given to it) is “Why should I not use the Microsoft.VisualBasic namespace in my C# code?”
First stop…..Google. Here I found a lot of “This
is great! I can reference VB.Net in my C# code and get the IsNumeric
and financial functions without having to rewrite them!” Followed closely by “You shouldn’t do this. It’s not natural.” So my quest continues on.
Next stop….my bookshelf for a copy of Practical Guidelines and Best Practices from Microsoft Press. Again I am thwarted in my attempt at enlightenment.
I have no idea what to say now. I suppose that the main argument that I
should have used was that we didn’t need to use the namespace for the
following code situation:
using Microsoft.VisualBasic; function void DoStuff() { double dblSomeVal = 0; if (Information.IsNumeric(dblSomeVal) == true) DoOtherStuff(dblSomeVal); }