Hey all. Problem: Java has many low level APIs, encouraging repetition of common code patterns, forcing error-prone error & edge case handling, and making verbose code.
Potential solution: be more deliberate about writing high-level utility functions and announcing their existence so others can use them. Some examples of high-level utility functions: FileUtils.writeStringToFile, FileUtils.delete (can recursively delete directories), IOUtils.safeStreamClose Are there code patterns that you find yourself repeating? These can be good places for utility functions. --- On that note, I just landed [1] some high-level file utility methods that allow users to ignore the complexity of closing resources and simplified error handling. In FileUtils: * read/writeJSONObjectFrom/ToFile * read/writeStringFrom/ToFile * read/WriteStringFrom/ToStreamAndCloseStream --- Some existing utils that I think are worth knowing about: * FileUtils * IOUtils.safeStreamClose * NetworkUtils (e.g. is on a restricted network?) * DrawableUtil (e.g. tinting drawables) * StringUtils (has URL specific manipulations) * ThreadUtils Note: many of our existing utilities do not document their edge cases and don't have tests so can be scary to use. We could get some great mentored bugs filed for writing tests for this code. - Mike (:mcomella) [1]: https://bugzilla.mozilla.org/show_bug.cgi?id=1267468
_______________________________________________ mobile-firefox-dev mailing list mobile-firefox-dev@mozilla.org https://mail.mozilla.org/listinfo/mobile-firefox-dev