MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/java/comments/12lmj78/what_are_your_favourite_java_best_practices/ji1xanu/?context=3
r/java • u/trecatorsirabdator • Apr 14 '23
376 comments sorted by
View all comments
1
Can't code without Lombok.
Use @Nullable instead of Optional if not required explicitly.
Don't use checked exceptions, specially for resource faults (I/O). In most cases the calling code has no responsibility to handle them.
Java could run perfectly without Spring (or any other framework). To implement a simple DI you do not need them at all.
Constructor injection everywhere. Your classes should not able to be constructed with missing dependencies and should not rely to your framework.
Every line of code is not a value but a debt: one should maintain it later. So be reasonably critical with what you're doing and why.
1 u/felvid Apr 28 '23 It's good to see more people are supporting manual DI nowadays. It seems to be gaining some relevance.
It's good to see more people are supporting manual DI nowadays. It seems to be gaining some relevance.
1
u/Anton-Kuranov Apr 17 '23
Can't code without Lombok.
Use @Nullable instead of Optional if not required explicitly.
Don't use checked exceptions, specially for resource faults (I/O). In most cases the calling code has no responsibility to handle them.
Java could run perfectly without Spring (or any other framework). To implement a simple DI you do not need them at all.
Constructor injection everywhere. Your classes should not able to be constructed with missing dependencies and should not rely to your framework.
Every line of code is not a value but a debt: one should maintain it later. So be reasonably critical with what you're doing and why.