Scott said:
My analogy to you was the "using" keyword (originally added to C# and now to
VB .NET 2005). Would using "using" in C# cause developers to have a harder
time understanding what Dispose() is all about? No. In that case, "using"
is just a compliment to the language, it enhances it. It's not required to
use it - - you can still use the more manual Dispose() method call for
clarity if you like, but "using" is just a short-cut, just like "Handles" is
a short-cut for something you can still do manually (and in many cases, want
to do manually).
I think the whole using thing is a terrible counter-example, because it is
rather clear that it only affects one block, and troubleshooting a
misunderstanding of this is in most cases trivial.
The VB.NET syntax issue Peter pointed out was more a case of asking the
question: How is a newbie programmer going to understand that when they have a
method that "Handles" an event that other things could already also be handling
the event?
While I could see the same newbie programmer failing to grasp that his object in
the using statement is no longer available after the following block, that is a
fairly straightforward thing to troubleshoot, and the errors in the code will be
rather apparent.
From personal experience, I've seen developers (in the process of learning)
just assume that because it says the method "Handles" the event, that only their
method handles the event. Whether you want to insult their intelligence or
learning methods is really irrelevant, what it boils down to is I've seen it
cause confusion. Most of the time explaining it using the alternate syntax
(AddHandler/RemoveHandler) seems to clear it up, because they then get it's a
list of Handlers, not just one method doing it all.
This is of course not a discussion of one language being superior to the other
or anything like that. Pete just said he didn't like the keyword because in his
experience (obviously similar to my own) it can/does lead to confusion. What
this amounts to is arguing about someone else's personal experience.
Chris.