java answers
Yegor Bugayenko edited this page Nov 15, 2019
·
20 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 two many things at the same time: saving, loading, filtering
- The class is not thread-safe, despite the promise in JavaDoc
- There is an obvious code duplication in
getContent*
methods - 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
-
while ((data = i.read()) > 0)
is a bad style, should bewhile (true)
and thenbreak
inside - Input stream and output stream 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 -
file
is not prepended withthis.
If you miss the first three problems, we won't work with you.