I have seen in many comments and answers that it is a bad practice to omit break lines. I personally find this very useful in some cases.
Let's just take a very simple example. This is probably not the best, just take it as an illustration:
- if the login is unsuccessful, you need to register an unsuccessful attempt.
- for the third unsuccessful attempt, you want to log in and do something else (alert admin, block account, ...).
Since the same action is for the first and second attempts, there is no need to break between the two and rewrite the same commands a second time.
Now for the third time you want to do other things, as well as record a journal. First, perform other actions, then let it start (no break ) through the action log of the first and second attempts:
switch (badCount) { case 3: //only for 3 alertAdmin(); blockAccount(); case 2: //for 2 AND 3 case 1: //for 1 AND 2 and 3 errorLog(); badCount++; }
Imho, if it were crazy practice to have common code for different cases, the C structure would simply NOT allow.
source share