Re: Multiple returns vs. Single exit

Mark Gorokhov <[email protected]> Fri, 28 Dec 2007 15:50:45 -0500
Newsgroups gmane.comp.windows.devel.java.advanced
Message-ID <6BD989BB73712F41B1EDD1B8A32EA4C3087E33EA@EXCHANGEVS1.comtechtel.com>
Throwing exceptions is OK, but "continue" is discouraged.

Mark G.

-----Original Message-----
From: Discussion of advanced Java topics.
[mailto:[email protected]] On Behalf Of Mann, Ivan H
Sent: Friday, December 28, 2007 3:44 PM
To: [email protected]
Subject: Re: [ADVANCED-JAVA] Multiple returns vs. Single exit

These standards remind me of the COBOL programmer I knew who read a
"coding standard" that constants should not be used in code.  What this
meant was that a value used (for example) to indicate a tab location
should be used in a variable so that if the value were to change you
could change it in one place rather than have to look for all the
locations that used "5" and decide if they were tab stops or not.

Instead of understanding this, he sat down and punched up a deck of
cards (this is an old story) like this:

Set one to 1.
Set two to 2.
Set three to 3.

and so forth, up to 200.  Then, he duplicated this deck and put it into
every program he wrote and instead of using "5" to indicate the tabstop
he used "five".  If he ever needed a constant outside of his range, he
punched a new card and added it to the standard deck he carried around.

What he wound up with was harder to read than the original and no easier
to maintain.  Each program took about a foot more space in the card
drawers (like I said, an old story) and took noticably more time to
compile. 


A question: did the person who created this standard also forbid
throwing exceptions?  One of the reasons exceptions were put into
programming languages was to allow cleaner ways to exit from methods
under error conditions.  Just curious.

Ivan Mann

===================================
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