4 ms·
I used to prefer keeping a single return point in my methods, but over time this changed. Now I find myself returning as early as possible when there's an error
by drakonka 9y ago
I used to prefer keeping a single return point in my methods, but over time this changed. Now I find myself returning as early as possible when there's an error or some other failed condition from which the method can't/shouldn't continue. For my hobby project I'm using Go and have found that it especially promotes this practice - it encourages me to handle errors early and often; if I nested all of the error-related conditions my methods would get very messy very fast.