Skip to content

java answers

sigfried edited this page Dec 31, 2019 · 19 revisions

This a list of problems in the Java file, in order of importance (the biggest problems are on top):

  • It's not really a class, but a collection of utility procedures (see)
  • It is doing too many things at the same time: saving, loading, filtering
  • There is an obvious code duplication in getContent* methods
  • It is mutable, getters and setters should be removed and a constructor introduced
  • It doesn't implement any interfaces
  • Names like get/set would sound better than get/save
  • The class is not thread-safe, despite the promise in the Javadoc
  • Exception swallowing is an obvious mistake
  • Unicode filtering is done wrong, will break the content instead of filtering it
  • Variable names are very short and non-informative
  • String concatenation is very ineffective in terms of performance
  • It's better to use Files.readAllBytes() instead of manual reading/writing
  • while ((data = i.read()) > 0) is a bad style, should be while (true)
  • Input and output streams are not buffered
  • One-byte reading is ineffective, we should read to the memory buffer
  • Both streams are not closed after use
  • All non-modifiable variables should be final
  • i += 1 is not the best method of variable increment, should be ++i
  • file is not prepended with this.

If you miss the first three problems, we won't work with you.

Clone this wiki locally
You can’t perform that action at this time.