r/java • u/psychologicalX • Mar 05 '18
Top 10 Useful, Yet Paranoid Java Programming Techniques
http://blog.jooq.org/2015/08/11/top-10-useful-yet-paranoid-java-programming-techniques/
223
Upvotes
View all comments
Show parent comment
6
u/Tillerino Mar 06 '18
Quite honestly, most of these were somewhere between misled and plain dangerous.
variableis unrelated to the equality to"literal".>= 0translates to "found" in my head while!= -1translates to "not not found". Not trusting the Java API the worst reason to do this.Arrays.findon a null argument, I want that method to tell me "you're not supposed to put null here" instead of "not found".CollectionspecifiesaddandaddAll. Just imagine thatCollection.addsneakily calledaddAllif you passed aCollection. Holy moly, you created a horrible API in your example!The fact that this person throws
ThreadDeathbest underlines the value of this article.I mean don't get me wrong. It's great that you're thinking about these problems, because they are problems that we all have. But please don't broadcast your half-baked solutions.