I may date myself and/or expose some naivety about general good programming practice, but I have been under the impression that multiple exit points from a function or method is bad practice. In my opinion, it is bad practice because there is more code to check in the event that the function or method has a signature change and returns a different type. You need to check all return statements and verify that all return values are cast or declared to be the proper type. On the other hand, when writing the method / function, it can be more work to structure the code to return different values under different conditions.
That’s why I was surprised to see this Tip of the Day when I started up Android Studio. It instructs users to place the caret on any exit point and press Ctrl+shift+F7, and it will highlight all exit points.
This indicates to me that multiple exit points in Java are not only common, but the Android Studio developers seem to endorse it, while recognizing a problem that it can present in code maintenance.
I guess I will modify my own opinion of multiple exit points to: Multiple exit points are OK if your editing environment includes parsing and highlighting them. I wonder what Emacs can do with that.
What do you think? Call or click now!
Joe Wronski 1/18/2016