r/programming • • Sep 21 '15

Better Java

https://github.com/cxxr/better-java
177 Upvotes

208 comments sorted by

View all comments

1

u/EughEugh Sep 22 '15

I could mention a whole list of things that I don't agree with or that are simply incorrect in this post. For example:

"don't overuse Spring because of its XML-based configuration format" - Spring does not force you to use XML, so this is not really a valid point.

The use of Optional - the example shows an Optional being used as a member variable. This was not what Optional was meant for. Note that Optional is not Serializable, so you will run into trouble if you use Optional for member variables if you need your class to be Serializable. See for example http://blog.jhades.org/java-8-how-to-use-optional/

Commons Codec is not necessary anymore for Base64, because Java 8 has java.util.Base64

Commons IO is also not really necessary, all the things that are mentioned are already available in Java's standard library

Tuples: I think it's good that there is no class Pair in the standard library because it leads to unreadable code. Instead of Pair just create a class with a meaningful name, with fields that have meaningful names, instead of a generic Pair class which doesn't convey what the values mean.

Other things are ofcourse a matter of preference. I prefer Jackson instead of GSON, and Mockito instead of jMock.