• (nodebb)

    Frist off, it seems pretty clear this code got through every review it was exposed to. All zero of them.

  • Hanzito (unregistered)

    Frist off... now there's a nice invective!

    Frist off, ++!

  • (nodebb) in reply to WTFGuy

    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.

  • Michael S. (unregistered)

    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.

  • (nodebb)

    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"?

  • (nodebb) in reply to WTFGuy

    Frist off, it seems pretty clear this code got through every review it was exposed to. All zero of them.

    That's "zero++" to you, sir.

  • (nodebb)

    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

  • (nodebb)

    @Balor64 ref

    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"?

    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.

  • Duke of New York (unregistered)

    Where we're going, we don't need close().

  • (nodebb) in reply to WTFGuy

    leaving the encoding unspecified is probably the safer bet.

    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.

  • MRAB (unregistered)

    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...

  • (nodebb) in reply to dpm
    1. I would reject the code during reviews
    2. I would to to their manager and see if we can get this one fired ASAP
  • Officer Johnny Holzkopf (unregistered)

    The article's first sentence immediately reminded me of this: "I will take these cotton balls from you with my hand, and put them in my pocket." So I will take that code from you with my hand, and put it in my pocket...

  • SG (unregistered) in reply to Jer

    Agreed, the array conversion is certainly a relic of the pre-generics era (so 1.4 or earlier), and I've not seen new code written using Vector and Enumeration in 20+ years... the latter occasionally comes up with old bad APIs (bits of the servlet spec), but the former is pretty obscure these days. This has to be early-2000s code... maybe even late 90's...

  • (nodebb)

    Pff, why close a Fille? It's Java, objects are garbage collected! /s... (till you get a "senior" Java developer saying that seriously and you just want to go cry silently as far as possible).

    As for Charset, you folks all seem to expect whoever wrote that "thing" even knows what an encoding is. I wouldn't bet on it.

  • (nodebb) in reply to Ralf

    "Pff, why close a Fille? It's Java, objects are garbage collected! /s... (till you get a "senior" Java developer saying that seriously and you just want to go cry silently as far as possible)."

    Oof - that comment from a senior dev would send me into a spiral wondering how many files out there were missing lines of text because he didn't close the BufferedWriter and what the impact on processing would be. Hopefully no major accounting errors because of it!

  • Loopy Coder (unregistered)

    I also like that they created the enumeration as eUrls above the for loop, but then re-create it as e for the for loop.

Leave a comment on “Buff Reading”

Log In or post as a guest

Replying to comment #680423:

« Return to Article