home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!igor!thor!rmartin
- From: rmartin@thor.Rational.COM (Bob Martin)
- Newsgroups: comp.lang.c++
- Subject: Re: GOTO, was: Tiny proposal for na
- Message-ID: <rmartin.715526582@thor>
- Date: 3 Sep 92 13:23:02 GMT
- References: <2318@devnull.mpd.tandem.com> <rmartin.715001372@thor> <4192@papaya.bbn.com> <1992Sep2.131733.20676@terminator.cc.umich.edu>
- Sender: news@Rational.COM
- Lines: 44
-
- potts@itl.itd.umich.edu (Paul Potts) writes:
-
- |I use "goto" sparingly as well, and agree that it can be very useful in
- |cases, and even make code *more* readable. BASICally <grin> I use it
- |only to exit from loops where adding additional conditions to the loop
- |would make the code much more obscure and slow, or to skip down past a
- |piece of code to the end of the loop under some circumstances.
-
- |To make GOTO more readable, NEVER go backwards in your code, only
- |forwards; use only one GOTO in a block, and comment explicitly. If GOTO
- |is used only under certain conditions, the argument against writing
- |spaghetti code really doesn't apply.
-
- Paul, though you rail against the proscription of goto, you have
- simply replaced it with several proscriptions and warnings of your own
- making. You tell us NEVER to do some things, and to "skip down" in
- "some circumstances" and "use only one" in others.
-
- I am sure that there are others who might disagree with your "one goto
- per block" rule. Others may disagree with your "NEVER go backwards"
- rule.
-
- You don't have to make up your own rules. Some other guys, who have
- thought about it alot, have put together a pretty well thought through
- set of rules. Moreover, the industry has, for the most part, accepted
- those rules as valid. Moreover, it has been proven that those rules
- are always workable, and it has been shown that they help to make code
- more readable and maintainable.
-
- So, why invent your own?
-
- Now, granted, there are some cases where the rules of Structure
- Programming do not create the most efficient possible code. And in
- cases where efficiency is of primary importance, then the rules should
- be violated, without regret.
-
- But in most cases, there is no good reason to invent your own, ad-hoc,
- software methodology.
-
- --
- Robert Martin Training courses offered in:
- R. C. M. Consulting Object Oriented Analysis
- 2080 Cranbrook Rd. Object Oriented Design
- Green Oaks, Il 60048 (708) 918-1004 C++
-