We’re now well into our first Generic year in Java-land, and the jury is still pretty well out. For example, Ken Arnold attacks and Tor Norbye rebuts. Check out the comments on Ken’s piece for some fresh, intelligent contributions. As for myself, I’ve just genericized a bunch of infrastructure code, and the trade-off was pretty simple: I got rid of a ton of casts, and the users of my APIs will get rid of even more. On the other hand, I picked up a few compile-time warnings—yes, I do want an array like MyClass<K>[] dammit! (And I understand that the warnings are correct, and that where previously I had an un-flagged potential ClassCastException, now I can’t claim that I didn’t know.) I suppose there’s another benefit in that my APIs’ users won’t be able to put a Bicycle in a container designed to hold instances of Fish; is that a biggie? Personally, the compiler warnings irritate me more than the casts did, but if what Tor and some of Ken’s commenters are saying is right, I should just suck it up, because my users are benefiting.

author · Dad
colophon · rights
picture of the day
July 08, 2005
· Technology (90 fragments)
· · Java (123 more)

By .

The opinions expressed here
are my own, and no other party
necessarily agrees with them.

A full disclosure of my
professional interests is
on the author page.

I’m on Mastodon!