When the fuck will people learn to handle errors as soon as possible and return early? I have been reading the some code all day and the amount of nested:
if(okay) {
... 200 lines of code
} else {
is frustrating. the indentation is sometimes 6-7 tabs deep...

  • 4
    > ... 200 lines of code

    Which most likely merit being refactored into several subfunctions.
  • 5
    Been there, refactored much. The concept that prevents this called guard clauses. Explain it and send a mail to yor co-workers about it like I did. Some sources about it:


  • 2
    @SomeNone completely agree, you wouldn't believe how many .forEach were actually .map in disguise, O(n^2) lookups which could be just O(n) etc..
  • 0
    @hack Thank you for the links, I will surely use them
  • 2
    To be fair this IS failing asap :) the failure is just 1 branch away ;)

    readability is another thing
  • 1
    Interesting, I have co-worker that thinks otherwise 😝 They feel likely to seeing flow in spaghetti-nested logic rather than, once and for all, understand that the reason for further code execution lies behind top listed conditions that were not met and thus did not return.
    Though that argument can go long, as brackets placing, or tabs vs. spaces, etc.
Add Comment