Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I really like early returns for this reason.

if (someEdgeCase) {

  return SpecialValue;
}

const normalCase = a + b ...

It allows you to drop a case from working memory as early as possible. I believe this would be a +1 in cyclomatic complexity, but it shouldn't be. Cyclomatic complexity is not the whole story (nor do I think it tries to be).



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: