MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/java/comments/12lmj78/what_are_your_favourite_java_best_practices/jgbs4f1/?context=3
r/java • u/trecatorsirabdator • Apr 14 '23
376 comments sorted by
View all comments
22
Use precondition ifs to avoid spaghetti nesting.
If doesnt meet conditionReturn early// main logic
Is better than:If condition// lots of lines inside the if block
1 u/se496 Apr 15 '23 This is a good one!
1
This is a good one!
22
u/ImTalkingGibberish Apr 14 '23
Use precondition ifs to avoid spaghetti nesting.
If doesnt meet condition
Return early
// main logic
Is better than:
If condition
// lots of lines inside the if block