473,396 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Delegates?

13,262 8TB
The delegates white paper say they are not neccessary. I buy most of the arguments there. However it's possible to implement them in java (That article could have been improved by using generics in the code).
The questions I have are:
1.) Does using delegates imply that the design is not fully object oriented?
2.) Which is more object oriented? Inner classes + Reflection vs Delegates
Jul 5 '07 #1
5 1626
JosAH
11,448 Expert 8TB
The delegates white paper say they are not neccessary. I buy most of the arguments there. However it's possible to implement them in java (That article could have been improved by using generics in the code).
The questions I have are:
1.) Does using delegates imply that the design is not fully object oriented?
2.) Which is more object oriented? Inner classes + Reflection vs Delegates
None of the two buy you much over the other. A Microsoft 'delegate' simply
wraps an anonymous class thing around a method. It may allow for closures
(I have to look into that in a little more detail), but I suspect that it doesn't.
I might be wrong though.

At the least I find the name 'delegate' confusing; I'd call it a 'mimicker' or something.

kind regards,

Jos
Jul 5 '07 #2
r035198x
13,262 8TB
None of the two buy you much over the other. A Microsoft 'delegate' simply
wraps an anonymous class thing around a method. It may allow for closures
(I have to look into that in a little more detail), but I suspect that it doesn't.
I might be wrong though.

At the least I find the name 'delegate' confusing; I'd call it a 'mimicker' or something.

kind regards,

Jos
That's another thing about them. The name throws a bit of a cloud. I'd have thought in pure delegation, an object forwards both a request and itself to another object (as in the state pattern).
Jul 6 '07 #3
JosAH
11,448 Expert 8TB
That's another thing about them. The name throws a bit of a cloud. I'd have thought in pure delegation, an object forwards both a request and itself to another object (as in the state pattern).
The construct is more like a C/C++ function pointer and as we all know simple
interfaces and small (anonymous) class objects can do the same thing.

If I would've been Microsoft (god forbid!) I'd gone the whole nine yards and
implemented closures instead.

kind regards,

Jos
Jul 6 '07 #4
odefta
18
You can't use delegates in java!
The java events mechanism is different from C# for example.
I C# you declare a delegate, an event that use the delegate, a method that implements the code of event and so on...

In java you declare an event like...

import java.util.EventListener;
public interface WizardListener extends EventListener
{
public abstract void nextSelected(WizardEvent e);
public abstract void backSelected(WizardEvent e);
public abstract void cancelSelected(WizardEvent e);
public abstract void finishSelected(WizardEvent e);
}

Then implement this..and so on..

For details you can read:
http://www.javaworld.com/javaworld/j...javatip35.html
Jul 9 '07 #5
r035198x
13,262 8TB
You can't use delegates in java!
....
You can implement them if you want. Read my first post again.
Jul 9 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Jeffrey T. Smith | last post by:
Back when the new J2SE1.5 features were announced, there was a JavaLive community chat (http://java.sun.com/developer/community/chat/JavaLive/2003/jl0729.html) in which Neal Gafter explains the...
3
by: Sam | last post by:
I’m just starting to learn delegates. I’m at the very beginning. If I understand correctly, delegates are for when you want to pass a function as a parameter. For example the client provides a...
4
by: LP | last post by:
Hello! I am still transitioning from VB.NET to C#. I undertand the basic concepts of Delegates, more so of Events and somewhat understand AsyncCallback methods. But I need some clarification on...
4
by: AMDRIT | last post by:
I am trying to understand Delegates and where/when to use them. I can see one potential use of a delegate (on form closing, set the cancel property in the event arguments.) Does anyone have a...
6
by: =?Utf-8?B?Sko=?= | last post by:
I have a logger component that logs to multiple sources, ie textfile, eventlog etc. and I have two methods that depending on where I call up my logger comp. one of them will be called. For ex. if...
0
by: bharathreddy | last post by:
Delegates Here in this article I will explain about delegates in brief. Some important points about delegates. This article is meant to only those who already know delegates, it will be a quick...
6
by: =?Utf-8?B?T2xkQ2FEb2c=?= | last post by:
My question is regarding the use of delegates in C#. I see how .Net uses delegates to wire event handlers to events. It’s an object created by a single line of code by the system and that makes...
7
by: Siegfried Heintze | last post by:
I'm studying the book "Microsoft Visual Basic.NET Language Reference" and I would like some clarify the difference between events and delegates. On page 156 I see a WinForms example of timer that...
69
by: raylopez99 | last post by:
They usually don't teach you in most textbooks I've seen that delegates can be used to call class methods from classes that are 'unaware' of the delegate, so long as the class has the same...
9
by: raylopez99 | last post by:
Hello all— I’m trying to get the below to work and cannot get the format right. It’s from this example: http://msdn.microsoft.com/en-us/library/8627sbea(VS.71).aspx What it is: I’m trying...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.