r/programming • u/knife_sharpener • Feb 22 '15
Java Makes Programmers Want To Do Absolutely Anything Else With Their Time
http://www.forbes.com/sites/quora/2015/02/21/java-makes-programmers-want-to-do-absolutely-anything-else-with-their-time/
35
Upvotes
61
u/[deleted] Feb 22 '15
I agree to an extent - but I do think the Java community overembraces creation of single-purpose objects over just calling functions.
See this example from the Apache HTTP client docs:
First off, it's great that they used an ArrayList<> instead of a NameValueCollection() or something, but wouldn't the code be better like:
That's 33% less written code, with no real minuses other than implementation details are hidden.
It seems very endemic to Java libraries that the API is written to require the full power of the library, rather than being written to be simple to use. In this case, it's written to allow a lot of flexibility in how forms are encoded, in how name-value pairs are constructed, etc., at the cost of needing to build (unnecessary) HttpPost, NameValuePair and UrlEncodedFormEntity objects.
See also: Swing, Apache Lucene, Struts, many other popular frameworks.