Re: Java and Objective-C
Re: Java and Objective-C
- Subject: Re: Java and Objective-C
- From: Peter Duniho <email@hidden>
- Date: Sat, 7 Jun 2008 17:15:18 -0700
Date: Sat, 07 Jun 2008 14:08:46 -0700
From: Bill Bumgarner <email@hidden>
On Jun 7, 2008, at 1:54 PM, Denis Bohm wrote:
That is handled by the Java example above (via the "Object...
args"). A method with any number of arguments can be passed to
registerUndoWithTarget. So you could do something like:
undoManager.registerUndoWithTarget(this, "setFrame", true,
splineStruct);
So, Java *can* do dynamic dispatch, but cannot catch a method dispatch
automatically -- you effectively have to compose the method invocation
manually through a comparatively verbose API.
No, not really.
I haven't used Java's undo support, so I'll take Denis's word that it
uses the pattern he's showing. But it didn't need to, nor is there
anything to stop someone from making an undo manager more like Cocoa's.
In particular, you could simply create an anonymous inner class
implementing the Runnable interface (or some interface specifically
declared by the undo manager, if you prefer). The interface would be
implemented with a method that does whatever you want to happen when
the undo is performed.
If anything, it's my opinion that this (or, especially the C# version
where the method can stand alone without having to be wrapped in an
interface implementation) is actually more elegant than Cocoa,
because it doesn't rely at all on passing arguments. Yes, Obj-C can
because of the way it works handle passing the arguments in a more
implicit way, but there are patterns in C# and Java that avoid the
need to deal with arguments altogether.
But, as I said before...this sort of question seems just as off-topic
as the previous one. The only difference is that here you're trying
to establish Obj-C/Cocoa as superior, rather than inferior. But what
makes the discussion off-topic is that the discussion is considering
a ranking of the languages at all, not whether Obj-C/Cocoa comes out
on top or not.
Languages are what they are. Making assertions regarding the
superiority or inferiority of one over the other is pointless, and
likely to only lead to religious wars.
Pete
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden