Control Flow Coding Style

"Michael Hunger" <[email protected]>
Newsgroups gmane.comp.programming.language-of-the-year
Message-ID <[email protected]>
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.