3 ms·
I think it would help with clarity - too much nesting in a function can mean it's doing too much and might need splitting into several functions
by keedon 8y ago
I think it would help with clarity - too much nesting in a function can mean it's doing too much and might need splitting into several functions
- jeremy_wiebe 8y agoOne 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).
- oneeyedpigeon 8y agoI also find myself doing a similar thing in loops - 'continue'ing early instead of wrapping everything in conditionals.