When is break Broken?
The break keyword in languages such as C/C++ and Java accomplishes the same thing: It abnormally exits from a block of control code (i.e. a loop or switch..case statement). In fact, to avoid mid-method returns, you may need to place a break within a while(true) loop to escape from it. The use of break in these situations makes sense to me.
Another occasion where a break makes sense is when performance is a consideration, such as when checking for a condition within a for loop as this example shows:
private boolean loginUser(String username) { boolean found = false; for ( User user: Users ) if ( user.username.equals(username) ) { found = true; // login user here… break; } } return found; }
In my opinion, this break is fine, although it does upset code flow somewhat, and it can be considered as offensive as goto (it essentially jumps to the return statement in the method). However, since it does so only to avoid needless processing of all of the users in the list once the appropriate one is found, it's acceptable. Also, since the user-login processing is still done in place, and it's obvious when reading the code where that is, this use of break is even more acceptable.
Using more than one break in a loop, however, is not acceptable to me. This is just as bad as a mid-method return, as it makes the code more difficult to read and requires more analysis to determine where to make modifications to the code. Experience has shown me that in just about every case where multiple breaks exist within a loop, the code structure can be improved to avoid this and make the code more readable.