Re: Control Flow Coding Style

"Andrew Semprebon" <[email protected]>
Newsgroups gmane.comp.programming.language-of-the-year
Message-ID <[email protected]>
On Mon, Apr 28, 2008 at 4:55 AM, Michael Hunger <[email protected]> wrote:

> 1) there _must_ be a single point of exit for each method


If what you are going for is readability, this can be a good guideline.
However, it is a fairly common idiom, for example, to do checks for unusual
input conditions like nulls and return the result (or error) immediately
before hitting the main logic of the method. I find that style more readable
than a lot of nested if/else conditions to accomplish the same thing.

> 2) each if must have an accompanying else branch


That's just crazy talk. Why have extra lines of code you don't need?

--
Andrew Semprebon * http://semprebon.blogspot.com/
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.