[ProgSoc] Jumpy code

Nathan de Vries nathan at atnan.com
Mon Oct 12 12:55:47 EST 2009


On 12/10/2009, at 12:35 PM, John Elliot wrote:
> Does anyone have an opinion they'd like to share? Should
> return/break/continue be avoided in general?

I think you need to have good reasons to interrupt control flow early,  
but I wouldn't avoid the use altogether. I think it all comes down to  
the expectations set in the code -- if you break any kind of  
expectation you're going to confuse other developers, so *that's* what  
should be avoided.

I mix between non-jumpy (common), jumpy (fairly common) and a mixture  
(using K combinator [1]), depending on the language and what the code  
is actually doing. My biggest gripe with people who avoid breaking  
control flow early is that in the case where your code requires guard  
clauses [2], nested conditionals make it even more difficult to see  
what you're guarding against.


Cheers,

Nathan de Vries


[1] http://c2.com/cgi/wiki?EssAndKayCombinators
[2] http://c2.com/cgi/wiki?GuardClause



More information about the Progsoc mailing list