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 named loops.
- Message-ID: <rmartin.715004818@thor>
- Date: 28 Aug 92 12:26:58 GMT
- References: <714668024@thor> <6800007@tisdec.tis.tandy.com> <rmartin.714863091@thor> <2318@devnull.mpd.tandem.com> <KERS.92Aug27125606@cdollin.hpl.hp.com>
- Sender: news@Rational.COM
- Lines: 37
-
- kers@hplb.hpl.hp.com (Chris Dollin) writes:
-
- |In article ... rgp@mpd.tandem.com (Ramon Pantin) writes:
-
- | It is well known that to rewrite code that uses breaks, continues,
- | mid-function returns and gotos (in the most general case) you have to
- | either:
- | - Add state variables to the head of loops and additional tests
- | of these variables within the bodies of the loops; or
- | - State variables only tested at the head of the loops and
- | code duplication.
-
- |Isn't one (non-boolean) state variable enough? [Hint: call it ``PC''. When you
- |are enlightened, you will realise that just because it's *possible* to cast
- |your code in an obsessively structured fashion doesn't mean you *should*.]
-
- In fact, one BOOLEAN variable is sufficient, since all we are trying
- to do is decide when to terminate a loop. However, in many cases it
- is advisable to use more than one boolean variable so that after the
- loop exits, you can find out why.
-
- Unfortunately the PC is not a very good state variable. The state of
- the program often cannot be determined from the PC. However,
- structured programming uses the PC as a state variable more than non
- structured programming, since more of the significant program states
- are separated into individual pathways of their own.
-
- Although it is possible to obsessively ignore the lessons of the past,
- it doesn't mean that you *should*.
-
-
-
- --
- 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++
-