3 ms·
> I was made to have only one exit point for some projects Did they give any rationale for this?
by Hendrikto 9y ago
> I was made to have only one exit point for some projects
Did they give any rationale for this?
- mmcgaha 9y agoIt should be easier to reason about code when there is exactly one exit from a block. I am not sure this really applies when we are talking about guard clauses that are not deeply nested. So loop breaks and other shallow returns are OK, and can be good.
- seanwilson 9y agoIt was just cargo cult programming as far as I could see where what one senior developer said was taken as gospel. I tried arguing objectively against practices like this and several others but was ignored. It was so bad, I remember one time some of the junior programmers literally shaking their heads when they saw some functional programming language examples for the first time because multiple returns are idiomatic there. They couldn't explain why multiple returns were bad, just that they were bad. I don't find this uncommon though and understanding it's a time saving heuristic. People will accept a "best practice" from an authoritative source without question and only later start thinking about it objectively when it gets in their way somehow. If your team is ignoring objective arguments though then you're in a cargo cult.