Hacker News new | ask | show | jobs
by jeremy_wiebe 2808 days ago
One place where nesting makes things difficult is in error handling.

If at each potential error point you best one level, you quickly find yourself deeply nested.

I find the pattern of exiting early and having the “happy path” running to the end of the scope to make it much easier to comprehend a function (I’m sure there’s a term for this coding style but I can’t find the name of it at the moment).

1 comments

I also find myself doing a similar thing in loops - 'continue'ing early instead of wrapping everything in conditionals.