- Feature Articles
- CodeSOD
-
Error'd
- Most Recent Articles
- Teamwork
- Cuts Like a Knife
- Charge Me
- Que Sera, Sera
- Hot Dog
- Sentinel Headline
- Mais Que Nada
- Here Comes the Sun
-
Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Edit Admin
Frist off, it seems pretty clear this code got through every review it was exposed to. All zero of them.
Admin
Frist off... now there's a nice invective!
Frist off, ++!
Edit Admin
I admire the happy world you live in, where code reviews are actually meaningful and people care about non-optimal code --- it works, it gets approved. No one cares if it could be improved, there's a new sprint to worry about.
Admin
Don't forget that the original coder forgot to release resources in a finally block. I bet you they have IO issues due to the application keeping so many files open.
Edit Admin
They also didn't pass a character encoding parameter into FileReader, which means it's using their system's default encoding, whatever that is. To be fair, that'll probably always work for reading urls, but why rely on a "probably" when you could easily have a "definitely"?
Edit Admin
That's "zero++" to you, sir.
Edit Admin
I'd bet this code predates Java 8 significantly - the choice of using a Vector over and ArrayList and the use of the Enumeration type instead of Iterator gives a whiff that at least the tutorial or book they were using predates Java 1.2
Edit Admin
@Balor64 ref
Unless they also explicitly control the encoding used by whatever app & process to write that source file, choosing a specific encoding is no more "definitely" successful than is the system default.
if we want to assume the file is created on that same server by some process, leaving the encoding unspecified is probably the safer bet. Doubly so if this is software that's sold to multiple customers who might be anywhere on Earth. We'd like to believe Unicode solved all that, but it didn't completely.
Admin
Where we're going, we don't need close().
Edit Admin
I think I'd prefer it if they explicitly specified
Charset.defaultCharset()
to prove that this was their definite intent and that they hadn't just forgotten about it.Admin
Why did they count the records with
recCnt
? Was it because they didn't know that there's a method for that?Oh, wait a moment.
I see
vURLs.size()
later on...Edit Admin