Re: Multiple returns vs. Single exit
"Mann, Ivan H" <[email protected]> Wed, 16 Jan 2008 09:18:28 -0600
| Newsgroups | gmane.comp.windows.devel.java.advanced |
|---|---|
| Message-ID | <3E47D20FD1918B48AC434AA83B57529601CC0BAE@usplm215.amer.corp.eds.com> |
A much better policy would be "don't write code that is confusing and hard to interpret." The problem with that is non-programmers can't look at something and tell if it is confusing but they can look at something and tell if it has a return statement, and policies like that are written by non-programmers to impress other non-programmers. I was part of a small internal study a long time ago which determined that the idea flowchart to interpret would fit on one page and use boxes to refer to other full page flowcharts, just like subroutines. One of the results of that was the guideline that subroutines should fit on one page. Today we would fit them on a screen. If the method fits on a screen, all the returns are obvious and it is not difficult to interpret. Ivan Mann -----Original Message----- From: Discussion of advanced Java topics. [mailto:[email protected]] On Behalf Of Ted Neward Sent: Tuesday, January 15, 2008 10:33 PM To: [email protected] Subject: Re: [ADVANCED-JAVA] Multiple returns vs. Single exit Dogma is the root of all evil. Ted Neward Java, .NET, XML Services Consulting, Teaching, Speaking, Writing http://www.tedneward.com > -----Original Message----- > From: Discussion of advanced Java topics. [mailto:ADVANCED- > [email protected]] On Behalf Of Mark Gorokhov > Sent: Friday, December 28, 2007 11:52 AM > To: [email protected] > Subject: [ADVANCED-JAVA] Multiple returns vs. Single exit > > Our company has a coding standard which prohibits multiple returns > from a method. I think that mandating to use a single exit from a > method makes code less readable but I have to follow this standard. > > It seems to me that there is no agreement on this. Search returns many > entries. > > Vote for multiple returns: > http://ivan.truemesh.com/archives/000611.html > http://peripateticaxiom.blogspot.com/2006/03/functional-style-and- > multip > le-returns.html > http://mail.python.org/pipermail/tutor/2004-December/034134.html > http://www.javapractices.com/topic/TopicAction.do?Id=114 > > Vote for a single exit: > http://jroller.com/fra3k/entry/code_improvement_guidelines > http://www.extragroup.de/weblog/hmk/archives/002997.html > http://www.extragroup.de/weblog/hmk/archives/002999.html > http://whatimean.wordpress.com/2007/02/08/multiple-return-points-are- > bad > > > History & discussions: > http://osdir.com/ml/programming.language-of-the-year/2005- > 01/msg00043.ht > ml > http://www.codecomments.com/archive205-2004-12-340086.html > http://www.leepoint.net/JavaBasics/methods/method-commentary/methcom- > 30- > multiple-return.html > http://onthethought.blogspot.com/2004/12/multiple-return- > statements.html > > > This question is definitely not an advanced one but I'm interested in > your opinion. > > Thanks > Mark G. > > =================================== > This list is hosted by DevelopMentor. http://www.develop.com > > View archives and manage your subscription(s) at > http://discuss.develop.com > > No virus found in this incoming message. > Checked by AVG Free Edition. > Version: 7.5.516 / Virus Database: 269.17.11/1201 - Release Date: > 12/28/2007 11:51 AM > No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.516 / Virus Database: 269.19.2/1224 - Release Date: 1/14/2008 5:39 PM =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com