Java 1.5, implications for OO
I've been wondering what the exact details were for some time, and the new features have come up in a recent comment thread. I've been doing java for a while, and like more than a few people in my shoes, I've been meaning to read up on the new stuff in 1.5, but haven't quite got around to it yet. So I looked a little bit:
http://www.clanproductions.com/java5.html (the first link I found, I haven't looked further). Do people have better links? Is this link comprehensive?
These are the new additions according to that link:
* Generics
* for-each loop
* Autoboxing / unboxing
* Type safe enumerations
* Static imports
* Variable argument lists (varargs)
How do you feel about them? I like generics, for-each and static imports implicitly. They all solve things that have annoyed me for ages.
Typesafe enumerations are something I never use, so I don't care, but maybe I'll use them now that it's so easy, but without having my hands dirty, I can't state a preference either way.
Autoboxing and unboxing seemed cool, but someone has pointed out some possible areas of confusion WRT the various operators, i.e. == will not unbox, but will compare Integers (the objects, not the values), whereas <= will unbox. There's also the issue of caching, although I can't say I really understand that too clearly. Still, it's not like this makes it bad, it just seems that it means one has to be careful using this new toy.
so, can we:
int i = 1;
int j = 1;
i.equals(j);
and have it autobox for us? I know, I could test this myself, but whether it works or not, the idea is still interesting.
Lastly, there's the varargs. I always felt dirty using that in C++ (or C... whatever). I was horrified to see it in J1.5. I'm not sure why the parameter gets changed to an array and not to a Collection, which would have seemed neater to me. I can bet that a lot of older programmers wanted this feature. I'm sure I've heard my old man gripe about it, too. But, besides giving those older programmers something familiar, how much does it really add? When is it really appropriate to use this? How would one go about teaching students not to use this because they think it's neat because it might bite them in the arse down the road when the requirements change? How do we show them when it is appropriate (do I hear a new pattern)?
So, the post is on this topic, feel free to post your opinions either way, complain about performance or OOness (are they mutually exclusive... sometimes). I only learned half this stuff in the last week or so, so feel free to comment beginner questions or advanced, as you see fit. If I've missed any differences with J1.5 (did they do additional under the hood performance tweaks?), feel free to chime in.
http://www.clanproductions.com/java5.html (the first link I found, I haven't looked further). Do people have better links? Is this link comprehensive?
These are the new additions according to that link:
* Generics
* for-each loop
* Autoboxing / unboxing
* Type safe enumerations
* Static imports
* Variable argument lists (varargs)
How do you feel about them? I like generics, for-each and static imports implicitly. They all solve things that have annoyed me for ages.
Typesafe enumerations are something I never use, so I don't care, but maybe I'll use them now that it's so easy, but without having my hands dirty, I can't state a preference either way.
Autoboxing and unboxing seemed cool, but someone has pointed out some possible areas of confusion WRT the various operators, i.e. == will not unbox, but will compare Integers (the objects, not the values), whereas <= will unbox. There's also the issue of caching, although I can't say I really understand that too clearly. Still, it's not like this makes it bad, it just seems that it means one has to be careful using this new toy.
so, can we:
int i = 1;
int j = 1;
i.equals(j);
and have it autobox for us? I know, I could test this myself, but whether it works or not, the idea is still interesting.
Lastly, there's the varargs. I always felt dirty using that in C++ (or C... whatever). I was horrified to see it in J1.5. I'm not sure why the parameter gets changed to an array and not to a Collection
So, the post is on this topic, feel free to post your opinions either way, complain about performance or OOness (are they mutually exclusive... sometimes). I only learned half this stuff in the last week or so, so feel free to comment beginner questions or advanced, as you see fit. If I've missed any differences with J1.5 (did they do additional under the hood performance tweaks?), feel free to chime in.
