3 ms·
Before I heard about the single exit point rule, I have coded during many years using multiple exit points. I am complying with the rule for many years and I am
by reacweb 9y ago
Before I heard about the single exit point rule, I have coded during many years using multiple exit points. I am complying with the rule for many years and I am quite happy with it. The code is slightly more nested, very slightly longer to type. But OTOH, the style checker can spot mistakes in my code and there is less thinking about how I will structure my code to make it smarter.
IMHO, the gain is small but not smaller than the cost.
- SideburnsOfDoom 9y ago> single exit point rule, What makes it a "rule" or as sometimes said, a "law"? It's just a style, and it has pros and cons, cases where it helps, and cases where it hinders.
- z3t4 9y agoIt's interesting when style becomes rules, the years goes by and no one challenge the "best practice", languages and frameworks might change, but the rules stay, for no good reason. So yeh, why only one return !?
- SideburnsOfDoom 9y ago> So yeh, why only one return !? Because it was a good idea in C. it's pretty much irrelevant to Java, JavaScript, C#, Ruby, Python, Rust etc. But the rules stay, for no good reason.
- wutbrodo 9y ago> It's interesting when style becomes rules, the years goes by and no one challenge the "best practice", FWIW, I would start making plans to leave a company where any significant amount of my colleagues followed rules like this without challenging them or being able to articulate their rationale.