[2231] in java-interest

home help back first fref pref prev next nref lref last post

RE: interfaces are NO substitution for method pointers

daemon@ATHENA.MIT.EDU (Tako Schotanus)
Wed Sep 27 07:34:48 1995

From: Tako Schotanus <Tako.Schotanus@bouw.tno.nl>
To: "'Ken Arnold - Sun Labs'" <arnold@cocolat.East.Sun.COM>,
        "java-interest@java.Eng.Sun.COM" <java-interest@java.Eng.Sun.COM>
Date: Wed, 27 Sep 1995 10:03:00 +-100


>I suppose I'm not as wise as Arthur -- I'm going to take *one* crack
>at trying to convince.
>
>Using methods, if you want, say, a callback from a button click, you
>say something like this (in the officially approved signature):
>
>	void CancelButtonCallbackFunc(Button *button, void *my_data)
>	{
>		do_cancel((Operation *) my_data); // whatever
>	}
>
>Using an interface, it would look like this:
>
>	class CancelButtonCallback extends Button {
>		Operation	*my_data;
>
>		void pressed()
>		{
>			do_cancel();	// whatever
>		}
>	}

[stuff deleted]

>At the very worst, you can argue that the new system maybe has a very
>few more keystrokes.  You have to admit that it adds some type safety,
>and arguably OO cleanliness and reusability.  This doesn't sound like a
>problem to me.  In fact, it smells a lot like a *solution* to some
>problems.

Except of course that you might want to dynamically assign callback functions.
Now if somebody could explain to me how do *that* in an OO way I'd be very
happy to hear it. ;)

- Tako

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
_/               Tako Schotanus, TNO Bouwinformatica                    _/
_/   work: Lange Kleiweg 5, 2288 GH, Rijswijk, NL, tel: +31-15-842393   _/
_/       home: van Hasseltlaan 352, 2625 HZ, Delft, The Netherlands     _/
_/     E-mail: sst@bouw.tno.nl - URL: http://huizen.dds.nl/~quintess    _/
_/ Never let a dictator rule with peace; let peace rule like a dictator _/
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post