Generics? More like Specifics.

This is probably just me, but I was reading up on the J2SE 5.0 enhancements, and it struck me that the term "generics" seemed kind of backwards. Of course, the term probably trickled down from the (sometimes pedantic) world of high-level OO theory where things only have to make sense in an abstract sort of way, and in any case it has that don't screw with me, I'm a professional sound to it (like regular expressions), but if the feature lets me write this:

/\* gimme a string, dang it \*/
String foo = hash.get("bar");

...instead of this:

/\* gimme a string, and oh, by the way, make it a string \*/
String foo = (String) hash.get("bar");

...shouldn't they have called it "specifics"? It just seems to me that if you construct a Hashtable that returns a specific type rather than a generic type, then, well... hmm. Okay, so the feature rocks. Done talking now.

Comments:

I think you are looking at it backwards...

If you were writing a container class then instead of making it specific (ie only accept java.lang.Object or String) you can make it generic (so it can accept anything).

At least that's my idea.

Posted by Graham on June 22, 2005 at 10:11 AM MDT #

I guess that makes sense.

Posted by Greg Reimer on December 13, 2005 at 03:04 AM MST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

My name is Greg Reimer and I'm a web technologist for the Sun.COM web design team.

Search

Categories
Archives
« March 2015
SunMonTueWedThuFriSat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
    
       
Today