What do you prefer - methods with a single exit or multiple exits?
I was doing a code review the other day and noticed that the developer had coded multiple return statements (this was written in Java) into a method. I stated that I really, really didn't like this practice, but admitted that it was simply a style preference.
It got me thinking, though. Why did I have such an aversion to it? I did some searching and found more than one discussion about the issue. In general, it appears that the majority of the debaters are fine with multiple exits (the opposite of my preference).
Join my email list and be notified whenever a new post is published.
I don't spam. You may unsubscribe at any time.
An unsubscribe link is provided at the bottom of all notification emails, which are sent using the Mailchimp email delivery platform. Please read my complete privacy policy for exhaustive details.
Thank you! Your comment has been submitted and is awaiting approval.
Unfortunately, we were unable to process your submission.
You may either your submission or reach out via
It looks like you are using an older browser.
As such, most/all interactive functionality (such as submitting comments) has been disabled.
Please consider upgrading your browser.
Congratulations! You are now subscribed to this post and will receive an email notification whenever a new comment is added.
If you would like to unsubscribe, click on the unsubscribe link provided at the bottom of every notification email.
Unfortunately, we were unable to process your subscription confirmation.
You might want to try clicking through your confirmation email again.
Alternatively, you can submit another comment and again opt to subscribe to follow-up comments.
Leave a comment