• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generics Questions

 
Ste Graham
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With one thing and another (e.g. getting married) I took a break from the developer exam. I've just recently restarted and I'm ready to submit BUT when I originally started I was using Java 1.4. Obviously, I have to test and compile the code with 1.5 now. It's first time I've tried this and I'm getting errors when compiling about the use of generics in collections i.e:

"Sime Input files use unchecked or unsafe opertaions"

If I run the compile with -xlinit:unchecked argument i see the problematic lines. Up until now I haven't really used Java 1.5, and so generics is new to me. At the moment, even though I get the message when compiling, every things works fine without - do I need to alter my code to accomodate generics? Or can I leave as is?

Ste :-)
 
Mike Ngo
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I started out using 1.4 a month ago and decided to recompile and release it using 1.5. Since you use casting anyway for 1.4 collections, your app should run as is. I fix mine to get rid of the warnings but those are warnings about possible invalid cast.
 
Ste Graham
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mike.

If i don't re-code to deal with the generics issue, do you think I need to document this in my choices.txt file? I mean the reason i don't want to do it is because as far as I was aware I'd finished and don't want to be bothered to have go though the code changing stuff everywhere!!! Lazy, I know!!
 
Mike Ngo
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i don't re-code to deal with the generics issue, do you think I need to document this in my choices.txt file? I mean the reason i don't want to do it is because as far as I was aware I'd finished and don't want to be bothered to have go though the code changing stuff everywhere!!! Lazy, I know!!


Actually if you don't recode then your code is backward compatible with older
version of the jdk. Unless the grader recompiles your code or reading the source code, he/she would not be able to tell. It's up to you to mention it but I don't see it as a big issue.
I kept my code in cvs so I can get back the older version.
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should always thrive for your code to compile without any warnings.

If I were an assessor I'd subtract points for compiler warnings, probably quite a few too if they were as easily avoidable as the ones you're talking about.
 
Mike Ngo
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You should always thrive for your code to compile without any warnings.

If I were an assessor I'd subtract points for compiler warnings, probably quite a few too if they were as easily avoidable as the ones you're talking about.


It depends... There are tons of existing code in production that simply cannot be fixed just for compiler warnings.
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's existing code. You're however producing new code, and there is no excuse for compiler warnings in new code.

Whether you wrote it a year ago or not doesn't matter, it's not been delivered so it's new code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic