r/java • • 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

105 comments sorted by

View all comments

52

u/AlainBienvenue Mar 05 '18

Like the author, as someone who has been coding in Java since 1999, I do not see anything wrong or even paranoid with any of these. Just good practices.

12

u/random314 Mar 05 '18

I don't enforce the always final rule, I've seen it done before but never really myself. Is it considered a very good practice? If so I might propose it to my team (we have a "good practice" checklist) in our next retro.

10

u/Yoghurt114 Mar 05 '18

I can highly recommend enforcing it. 99 out of 100 times you violate this rule, it's a bad approach and there's a better solution out there.

It's just a formatting preference in the IDE anyhow, no extra effort needed if your code already abides by the side of sanity.

7

u/GeorgeMaheiress Mar 06 '18

The downside is extra effort reading. I find the line noise of final variables more awkward than helpful, especially since Java tends towards long lines of code anyway, and most methods are short enough that it's already obvious if a variable is reassigned.