Which do you prefer?

  • Thread starter Master Programmer
  • Start date
M

Michael C

Master Programmer said:
Good programming is about leaving breadcrumbs for the next person. Not
trying to show off by writting code that is not immediatly obvious. If
it needs any comments to describe it - then you are a useless
programmer.

Hardly. I'd say if it needs comments to describe it and those comments are
missing then you're a sloppy programmer.

Michael
 
B

Blake

You obviously don't do any async programming with .NET then?

If you don't know how to manage handlers yourself you will be in
trouble.

The Handles keyword is fine for wiring simple button click events.
Thats is the reason it is in VB and not C#

Someone at MS (rightly) assumed that handlers would be too conceptually
hard for some VB programmers. I guess they were right.

You just keep handling your button clicks and leave the real coding to
the professionals :)
 
R

RobinS

Michael C said:
I'm not sure that would be a good idea. The handles keyword supports the
designer where I presume the AddHandler does not.

Michael

What do you mean by that? You mean the designer, in terms of
double-clicking on the button to create the framework of
the event, or using the dropdowns?

Robin S.
 
M

Michael C

RobinS said:
What do you mean by that? You mean the designer, in terms of
double-clicking on the button to create the framework of
the event, or using the dropdowns?

Either.

Michael
 
A

aaron.kempf

you're full of shit its not necessary it's too verbose
you're full of shit its not necessary it's too verbose
you're full of shit its not necessary it's too verbose
 
A

aaron.kempf

if it takes 30% more verbosity for 80% of the stuff that i do; then by
definition-- it's not worth it.

-Aaron
 
T

Tom Leylan

Hi Michael:

I think you'll find it is a good idea. It isn't easy for me to explain and
it has a tendency to draw out the "my language is better than yours" folks.
But for some 25 years I have cautioned people against using language or
platform "unique" solutions. The definition of a language-unique feature
would be one that isn't (generally) found in other languages. So variables,
functions loops and conditional tests aren't unique and should be used.
Something like instantiating a variable upon first use (the opposite of
OPTION EXPLICIT) is uncommon and generally a bad practice so I caution
people to avoid it. Unique features make it harder to translate from or to
other languages. dBASE for instance had a CLEAR ALL command which was
"easy" in some people's eyes but horrible from the perspective of a software
developer.

In any case the AddHandler syntax permits you to disable handlers, or to
change handlers at runtime and it is the mechanism used in C#. Similar
"handler-like" assignments are available in other languages but nothing but
VB.Net is going to have "Handles Button1.Click" type syntax. Reliance on
these types of things tends to lead to "VB programmers" instead of
programmers who use VB.

Your mileage may vary...

Tom
 
M

Michael C

Tom Leylan said:
In any case the AddHandler syntax permits you to disable handlers, or to
change handlers at runtime and it is the mechanism used in C#. Similar
"handler-like" assignments are available in other languages but nothing
but VB.Net is going to have "Handles Button1.Click" type syntax. Reliance
on these types of things tends to lead to "VB programmers" instead of
programmers who use VB.

Your mileage may vary...

You have an excellent point and agree in the majority of cases but not sure
about this one. There is extra work involved and I think it would be a
hassle not using the designer for events. I presume you can't double click
buttons to go to the code it executes and have to find this code manually.
It might not even be called buttonName_Click so you'd have to find the
AddHandler first. There's also the problem that it would be very easy to
accidentally add the event twice by double clicking a control. Basically
you're missing out on a large amount of functionality and adding some hassle
just to avoid a language specific keyword that would be very easy to
translate should the need arise.

It might just be easier to use C#. Using AddHandler in vb seems to me like a
programmer who wants to use c# but can't or won't for some reason :)

Michael
 
C

Cor Ligthert [MVP]

Michael,

You know that it is more work to remove a method with handler in C# than in
VB.Net?

Cor
 
T

Tom Leylan

You can't double click the button and get to anything but the "Click"
handler can you? There are all sorts of handlers one could potentially want
to reference.

But it is much more than simply a matter of easier... as I pointed out the
Handles syntax isn't dynamic and can't be made dynamic. It is a simple
matter to point multiple controls (or events) to a single handler using
AddHandler() And it most likely isn't named buttonName_Click()... I don't
program "click handlers" I develop functionality which happens to execute
when a button is clicked. This gives one the flexibility to reassign the
handler to a different button or even a different non-button control.

It isn't about being a C# wannabe... C# is a case-sensitive language that
uses curly braces to delimit blocks of code and semicolons as line
terminators. I don't see any advantage to a case-sensitive language.

In any case I think you should continue to use the syntax you're happiest
with and I'll do the same :)

Nice chatting with you.
Tom
 
M

Michael C

Cor Ligthert said:
Michael,

You know that it is more work to remove a method with handler in C# than
in VB.Net?

Yes that is true, however it is only a small amount of extra work and
impossible to forget as it gives a compile error.

Michael
 
R

RobinS

I guess I don't mind using the Handles if there's not
a pattern to it. For example, if I wanted to hook up
the MouseEnter and MouseLeave event for all the textboxes
on the screen, then I'd use a loop and AddHandler.
But for one button's click event, I'd do the Handles
thing. Oh, dear, that means I'm mixing methods.

Robin S.
----------------------------
 
R

RobinS

I don't really see that it adds verbosity in terms of typing,
since if you double-click on the button, or use the dropdowns
in Visual Studio, it creates the framework of event code for you.
Mathematically speaking, I believe that's an even match -- 50%/50%.

Robin S.
 
M

Michael C

Tom Leylan said:
You can't double click the button and get to anything but the "Click"
handler can you?

No, but you can use the designer to get to other events by clicking on the
event tab (I presume vb has this?). Double clicking will only ever get the
default event, which in most cases is good enough, but with the designer
event window you can see all the events.
But it is much more than simply a matter of easier... as I pointed out the
Handles syntax isn't dynamic and can't be made dynamic.

In the rare case you need it to be dynamic (and these cases are quite rare)
then don't use the Handles keyword.
It is a simple matter to point multiple controls (or events) to a single
handler using AddHandler()

You can also do the same thing in the designer.
It isn't about being a C# wannabe... C# is a case-sensitive language that
uses curly braces to delimit blocks of code and semicolons as line
terminators. I don't see any advantage to a case-sensitive language.

I don't use the case-sensitivity but there are many other reasons to use it
and none of the items you've listed here are reasons not to use it.
In any case I think you should continue to use the syntax you're happiest
with and I'll do the same :)

Nice chatting with you.

Oh, ok, see ya tom :)

Michael
 
A

aaron.kempf

fully agree tom

I just don't want to be on the losing side of this argument.. if 90% of
the .NET programmers use C# then what are we doing here?

I just think that MS dealt us a raw deal; and I'm not willing to invest
my time in a new Microsoft-centric language.

I would rather use the old one-- than spend years gettign up to speed
only to find out that MS has killed the language after all.

I listened to rumors about MS Access for the past 10-15 years; and I
refuse to invest in an uncertain language again.

until Microsoft restores the 'VISUAL' and the word 'BASIC' to my
langauge they can lick my nuts

-Aaron
 
A

aaron.kempf

I don't care if the wizard generates the code.

it shouldn't be visible.. all it is, is that it's unnecessary and too
much work.

extra work + more extra work + no added benefits <> 50% / 50%

it's time to put the VISUAL and the BASIC back into VB

-Aaron
 
T

The Grim Reaper

Plenty of people look up to me :D
__________________________________
Grim
(Lead Engineer/HMI Technical Specialist/.NET Programmer)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top