Re: Multiple returns vs. Single exit
"Mann, Ivan H" <[email protected]> Fri, 28 Dec 2007 14:58:07 -0600
| Newsgroups | gmane.comp.windows.devel.java.advanced |
|---|---|
| Message-ID | <3E47D20FD1918B48AC434AA83B57529601BA0CA5@usplm215.amer.corp.eds.com> |
My standard reply around here is, "I get paid by the hour." If that is what they are paying you for, then by all means spend all the hours it takes to do what they say, and cash the paycheck, but don't think that what you are doing makes the programs easier to read or easier to maintain. You will get paid for the time it takes to figure out what the spaghetti code surrounding the returns means, too. Or, somebody else will get paid for it. Ivan Mann -----Original Message----- From: Discussion of advanced Java topics. [mailto:[email protected]] On Behalf Of Mark Gorokhov Sent: Friday, December 28, 2007 2:51 PM To: [email protected] Subject: Re: [ADVANCED-JAVA] Multiple returns vs. Single exit 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(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