With almost all code I write, I am often dealing with set reduction problems on collections that ultimately end up with naive \"if\" conditions inside of them. Here\'s a simple
One style that gets used enough to mention, but hasn't been mentioned yet, is:
for(int i=0; i
Advantages:
DoStuff();
when condition complexity increases. Logically, DoStuff();
should be at the top-level of the for
loop, and it is.SOMETHING
s of the collection, without requiring the reader to verify that there is nothing after the closing }
of the if
block.Disadvantages:
continue
, like other flow control statements, gets misused in ways that lead to hard-to-follow code so much that some people are opposed to any use of them: there is a valid style of coding that some follow that avoids continue
, that avoids break
other than in a switch
, that avoids return
other than at the end of a function.