PyChecker messages

John Roth newsgroups at jhrothjr.com
Mon Jan 17 18:55:18 CET 2005


"Ben Sizer" <kylotan at gmail.com> wrote in message 
news:1105983271.574296.37740 at c13g2000cwb.googlegroups.com...
> But you could use a dict of return values, or even just assigning a
> different return value in each if clause. The end result is that you
> have a single well-defined exit point from the function, which is
> generally considered to be preferable.

Preferable, but not any form of an absolute. "Single Exit"
was one of the recommendations from the early structured
program work back in the 70s, and the industry has long
since sent it to the dustbin of history.

The issue is a simple one of clarity, and woodenly applying
the single exit rule where it doesn't belong frequently
winds up creating nested if-elif-else structures and extranious
flag variables.

If an embedded return isn't clear, the method probably
needs to be refactored with "extract method" a few
times until it is clear.

John Roth
> 




More information about the Python-list mailing list