Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

Hi! I found these articles about Delegates.

 

In this one Sun is explaning why Java doesnt support Delegates and will never do.

http://java.sun.com/docs/white/delegates.html

 

And on this one is Microsoft response to Sun's white paper.

http://msdn.microsoft.com/archive/default.asp?url=/ARCHIVE/en-us/dnarvj/html/msdn_deltruth.asp

 

I guess I was pretty convinced by Microsoft arguments.

So what do you guys think?

Edited by Cassio
  • *Experts*
Posted

I think the argument can be summed up with this statement, from MS:

The truth is that delegates are simpler than inner classes for event scenarios.

 

When I want to maintain something, I want simplicity. I don't care about saving 2 nanoseconds on an event. Generally speaking, whatever code is running in the event is going to be significantly longer than the time it takes to get into the function/method.

 

I'll agree that delegates are a bit weird (a new Type and they have global scope) and confuse most people at first. Truth is, most Windows programmers won't use them except as event handlers for their controls.

 

If you invest some time in learning "true" OO programming, you will find many more uses for them - they form the basis for notification between components. As the recent "Design Patterns in C#" book mentions, you can use interfaces to accomplish the same thing, but delegates make the code "cleaner" - that is, easier to view and understand.

 

-nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...