in

ASP.NET Weblogs

Philip Rieck

Phil in .net

VB.net operator overloading, static methods

Came across this this evening:

A brief description of the Operator Overloading feature.
[Cameron's Visual Basic Blog]

And liked what I read.  VB.NET gets what it's needed from day one (if you ask me); the ability to consume overloaded operators.. Being able to create operator overloads is a great bonus. Not that ClassName.op_Addition(left, right) is so bad to type, but... it's ugly.

While we're on it, it really exposes one of the things I hate (perhaps irrationaly) about VB.net - using static methods from an instance variable.  I'm sure that this is one of those things that now can never change (“it would break code“, they say), but I certainly consider it a mistake.  What does this mean:

Dim inst As Foo = New Foo
inst.prop = 1
inst.SMethod()
inst = Nothing
Foo.SMethod()
inst.SMethod()

If you ask me, it means that I'm going to be explaining what "shared" subs are to a bunch of people. I've lost count of the number of times I've seen a class with only Shared methods instantiated because that's what the developer thought they had to do to call methods on it.. After all, when I see the inst.SMethod() call, don't I have to use New on inst in order to prevent a NullReferenceException? VB.net and the Shared concept would probably be easier to teach (and learn) without this feature.

Published Oct 20 2003, 10:07 PM by philipr
Filed under:

Comments

 

Dave Bettin said:

Isn't everything in VB.Net ugly?
October 21, 2003 12:17 AM
 

Philip Rieck said:

Dave, I can't (YES) answer your question (YES)

I hate to (YES) say something (YES) like that, since it (YES) is purely a personal preference (YES) and not really anything other than a religious debate (YES!!).
October 21, 2003 8:36 AM
 

Joe Grossberg said:

I would add, as a corollary to that, the observation made by my friend, a high school math teacher:

"No one wants to admit their kid is dumb."

Even though about half the kids are necessarily below average.
October 21, 2003 12:00 PM
 

LongHorn said:

Use any language you want, but most importantly write Bug Free Applications ;)
April 8, 2004 8:36 AM

Leave a Comment

(required)  
(optional)
(required)  
Add