

My Opinion: Banning break and continue from your loops will improve code quality - javinpaul
http://www.sleepeasysoftware.com/banning-break-and-continue-from-your-code-will-improve-its-quality/

======
PaulHoule
This is an old fight which was settled (in the other direction) around 1980 by
looking at the example of linear string search. Without break the logic is
clearly contorted and hard to understand.

Now I don't argue at all that dropping out of a loop with return out of a
small method is preferable though.

------
chrisbennet
I think "break" and "continue" have their place. The code he used is a bit of
a straw man IMO:

 _while (someCondition) {

    
    
       if (someOtherCondition) {
    
           doSomeLogic();
    
           continue;  //jump to the top of the loop
       }
    
       doSomeOtherLogic();
    
       break; //exit the loop
    

}_

Compare this to how I use "break" and "continue"

 _for (int j = 0; j < nSomethings; j++) {

    
    
        int nDroidsLeftInQ = GetNDroidsInQueue();
        if (nDroidsLeftInQ == 0)
            break; // blow this clambake, we're done
    
        Droid droid = GetDroidFromQueue();
    
        // Skip droids that aren't even close
        bool theseArentTheDroidsWereLookingFor = (DroidFitnessTest(droid) == -1);
        if (theseArentTheDroidsWereLookingFor )
          continue;
    
        // 30 more lines code where the work actually gets done
    
        doSomeLogic1();
        doSomeLogic2();
        ...
    

}_

------
elviejo
Dijkstra said it before: "Go To Statement Considered Harmful"[1] And Break and
Continue are just forms of GoTo.

[1]
[http://www.u.arizona.edu/~rubinson/copyright_violations/Go_T...](http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To_Considered_Harmful.html)

