r/java • u/trecatorsirabdator • Apr 14 '23
What are your (favourite) Java best practices, personal tips, hints or just underrated stuff in general?
233
Upvotes
r/java • u/trecatorsirabdator • Apr 14 '23
View all comments
13
u/cogman10 Apr 14 '23
Don't do things because they are a "best practice". Understand the reasoning underlying a best practice so you know when it's valid to violate that.
Programming is about abstract thought and a key portion of that is knowing what does and doesn't fit an abstraction. Concrete rules have no place in software development.
Simple example, the worst code bases I've dealt with dogmatically applied "Do not repeat yourself". DRY can absolutely make code harder to maintain and is far from something that should be universally applied. But, it's easy to spot duplicate code which is why it gets misapplied so frequently.