NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Java (Score:2)
My first realization that I really wasn't "thinking" Java was when I wanted a dispatch table whose keys were anonymous subs closing over values determined at runtime. I wound up creating a class hierarchy and used polymorphism to handle the dispatching. Instead of having all of my logically connected behavior in one place, I wound up spreading it across multiple classes which were created solely for the purpose of handling this dispatching. Being forced to shoehorn everything into "one-size-fits-all-OO-s
Re:Java (Score:2)
There's actually a semi-decent way to handle some of that. You define an abstract class (or interface) with the method you want to be able to call. Then, you define anonymous inner subclasses of that class:
Not sure if that would have fit the bill or not, but it's easier than making explicit subclasses for every single one of those!
J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers
Reply to This
Parent
Re: (Score:2)
Wow. Ugly as hell, but yet, much better than what I wrote. Reminds me of how some Java programmers argue that they don't need closures because they have anonymous inner classes. It's true, I suppose, but it's an awful lot of grunt work.
As you can see, I'm not much of a Java hacker :)
Re: (Score:2)
Well, I just completed a class where I actually had to use this technique, and I'll testify that I definitely would've rather had something else. And you're right; it is ugly. In my case I don't think it was closures I was looking for, but I'm not sure what it was.
The good news is I replaced it with something even more amazing.
J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers