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
15
u/depressiown Feb 22 '15
This bit of code annoys me for several reasons:
Unless you're using something specific to the implementation type, you could use the interface: Map<String,Set> depMap = new HashMap();
He's not using the diamond for the generic types: Map<String,Set> depMap = new HashMap<>();
He's not typing the Set: Map<String,Set<String>> depMap = HashMap<>();
Could use Guava to abstract the inner collection: Multimap<String,String> depMap = HashMultimap.create();
Articles/comments like these constantly annoy me. They're written by people who really aren't that familiar with clean, modern Java. Lambdas, ORM, libraries of annotations... there's so much stuff out there to simply how much Java you write and make it much cleaner than all these examples people use of why Java is bad.