3 ms·
I agree with you. I think the statement (ish) “don’t use if/else, use return” deserves some qualification, and one natural place to use it is for errors. When
by chaboud 9y ago
I agree with you.
I think the statement (ish) “don’t use if/else, use return” deserves some qualification, and one natural place to use it is for errors.
When people start dropping returns all over massive multi-screen branching and looping structures, readability may suffer, and debugability quite often takes a big hit.
In general, I like to use guard clauses for any big at-entry branch asymmetries. If they’re farther down the logic tree and/or unwieldy, it may be time to call some more functions.