Re: Control Flow Coding Style

"jonnyyu2" <[email protected]>
Newsgroups gmane.comp.programming.language-of-the-year
Message-ID <[email protected]>
I think both are right, so here are some more specific descriptions I 
used.
1) error checks, and trivial case handling, I return them immediately.
it could also help me control the nest level when having a lot of 
condition checks.

2) when non-trivial codes begin, I normally define a return temp 
variable and keep single exit point. This helps in debugging a lot.

-Jonny


--- In [email protected], "Michael Hunger" <pragmatic@...> 
wrote:
>
> I recently looked at a code review method which is based on rigid 
rule
> checking.
> 
> Two rules bothered me so I started a heated discussion with a 
colleague.
> I'd be interested in your opinions.
> 
> 1) there _must_ be a single point of exit for each method
> 2) each if must have an accompanying else branch
> 
> My colleagues view:
> Both are right.
> It simplifies the maintainability and the ability to add new 
aspects to a
> program to have a single point of input and output.
> Return is a kind of goto and should be avoided (create spaghetti 
code)
> 
> My view:
> Both are overengineering (if enforced).
> * fail fast
> * simplify control flow
> * one thing at a time, no context to carry around
> * guard-clauses and precoditions (default returns)
> * result variable has much to broad scope
> * avoid control flow on content of result variable
> 
> What do you think ?
> 
> Michael
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.