IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Great - another perfectly good term hijacked and hosed
A [link|http://www.stepwise.com/Articles/Technical/2000-03-03.01.html|delegate] in Cocoa (Objective C) is something like this:
\n@interface NSApplication // system class\n{\n   id _delegate;\n   ...\n}\n-setDelegate: d;\n-(void)quit;\n\n@end\n\n\n@interface MyApplicationDelegate\n\n-(BOOL)applicationShouldQuit: sender;\n//-(void)applicationWillQuit: sender; // not implemented\n\n@end\n\n@implementation NSApplication\n\n-quit\n{\n   // this isn't exactly how its done but you get the idea\n   if([_delegate respondsToSelector: @selector(applicationShouldQuit:)] &&\n      [_delegate applicationShouldQuit: self])\n   {\n      if([_delegate respondsToSelector: @selector(applicationWillQuit:)])\n      {\n         [_delegate applicationWillQuit: self];\n         // proceed with quitting\n      }\n   }\n}\n\n@end\n

Its a way of adding additional behavior to an object by delegating key behavior to another object. Its used all through the Cocoa apis and its really useful since you just implement the methods to get the notifications you care about in your delegate - no subclassing required most of the time.

Somehow, I doubt this is what C# means by delegation.
Edit - inserted pre tags



"Whenever you find you are on the side of the majority, it is time to pause and reflect"   --Mark Twain

"The significant problems we face cannot be solved at the same level of thinking we were at when we created them."   --Albert Einstein

"This is still a dangerous world. It's a world of madmen and uncertainty and potential mental losses."   --George W. Bush
Expand Edited by tuberculosis Feb. 16, 2005, 12:47:54 PM EST
Expand Edited by tuberculosis Feb. 16, 2005, 01:47:44 PM EST
New Not the first time

Domain (Internet or Windows networking?)

Network printer (NOT "a printer attached to a network", but "a printer connected to a Windows PC and being shared across the network")

Innovation (Hmm...no comment)

Tom Sinclair

"This is a lovely party," said the Bursar to a chair, "I wish I was here."
-- The Bursar is a man under a *lot* of stress
(Terry Pratchett, Lords and Ladies)
New Hurrah!


Peter
[link|http://www.ubuntulinux.org|Ubuntu Linux]
[link|http://www.kuro5hin.org|There is no K5 Cabal]
[link|http://guildenstern.dyndns.org|Home]
Use P2P for legitimate purposes!
Expand Edited by pwhysall Feb. 16, 2005, 01:59:18 PM EST
New dunno about C#
but the code you describe is essentially Java AWT/Swing event handling mechanism. Has been since 1.1.

\ninterface WindowListener\n{\n    public void windowClosed(WindowEvent e);\n    public void windowClosing(WindowEvent e);\n}\n
--


- I was involuntarily self-promoted into management.

[link|http://kerneltrap.org/node/4484|Richard Stallman]

New Except you have to implement the whole interface
and delegation is not always about event notification - for instance, EOModels (meta models that are used in ORMapping) have a default method of finding related model files. However, you can add a delegate to the model group that will get called whenever a search for a model file fails - thus allowing you to prompt the user for it, or implement alternate search paths.




"Whenever you find you are on the side of the majority, it is time to pause and reflect"   --Mark Twain

"The significant problems we face cannot be solved at the same level of thinking we were at when we created them."   --Albert Einstein

"This is still a dangerous world. It's a world of madmen and uncertainty and potential mental losses."   --George W. Bush
New Oh, I just gave the most pervasive example
There are others.

And BTW, windowClosing() is actually supposed to hide the window. If your idea of "close" is something else, you can use windowClosing() to change the behavior.


Also, sometimes Java library provides default implementation of the interfaces involved, which makes it easier to write your own implementation - you don't have to implement all methods.
--


- I was involuntarily self-promoted into management.

[link|http://kerneltrap.org/node/4484|Richard Stallman]

New Actually, that appears to be very similar.
I'll post an example later when I get a chance.
--
Chris Altmann
New Never mind. They are different.
--
Chris Altmann
     Great - another perfectly good term hijacked and hosed - (tuberculosis) - (7)
         Not the first time - (tjsinclair)
         Hurrah! -NT - (pwhysall)
         dunno about C# - (Arkadiy) - (2)
             Except you have to implement the whole interface - (tuberculosis) - (1)
                 Oh, I just gave the most pervasive example - (Arkadiy)
         Actually, that appears to be very similar. - (altmann) - (1)
             Never mind. They are different. -NT - (altmann)

If your role can be replaced by Keanu Reeves miming walking into a non-existent wall, then you probably need to go back to waiting tables at the Ground Round--make that the homeless shelter.
115 ms