home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / cplus / 13011 < prev    next >
Encoding:
Internet Message Format  |  1992-08-29  |  2.0 KB

  1. Path: sparky!uunet!igor!thor!rmartin
  2. From: rmartin@thor.Rational.COM (Bob Martin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: GOTO, was: Tiny proposal for named loops.
  5. Message-ID: <rmartin.715004818@thor>
  6. Date: 28 Aug 92 12:26:58 GMT
  7. References: <714668024@thor> <6800007@tisdec.tis.tandy.com> <rmartin.714863091@thor> <2318@devnull.mpd.tandem.com> <KERS.92Aug27125606@cdollin.hpl.hp.com>
  8. Sender: news@Rational.COM
  9. Lines: 37
  10.  
  11. kers@hplb.hpl.hp.com (Chris Dollin) writes:
  12.  
  13. |In article ... rgp@mpd.tandem.com (Ramon Pantin) writes:
  14.  
  15. |   It is well known that to rewrite code that uses breaks, continues,
  16. |   mid-function returns and gotos (in the most general case) you have to
  17. |   either:
  18. |       - Add state variables to the head of loops and additional tests
  19. |         of these variables within the bodies of the loops; or
  20. |       - State variables only tested at the head of the loops and
  21. |         code duplication.
  22.  
  23. |Isn't one (non-boolean) state variable enough? [Hint: call it ``PC''. When you
  24. |are enlightened, you will realise that just because it's *possible* to cast
  25. |your code in an obsessively structured fashion doesn't mean you *should*.]
  26.  
  27. In fact, one BOOLEAN variable is sufficient, since all we are trying
  28. to do is decide when to terminate a loop.  However, in many cases it
  29. is advisable to use more than one boolean variable so that after the
  30. loop exits, you can find out why.
  31.  
  32. Unfortunately the PC is not a very good state variable.  The state of
  33. the program often cannot be determined from the PC.  However,
  34. structured programming uses the PC as a state variable more than non
  35. structured programming, since more of the significant program states
  36. are separated into individual pathways of their own.
  37.  
  38. Although it is possible to obsessively ignore the lessons of the past,
  39. it doesn't mean that you *should*.
  40.  
  41.  
  42.  
  43. --
  44. Robert Martin                        Training courses offered in:
  45. R. C. M. Consulting                       Object Oriented Analysis
  46. 2080 Cranbrook Rd.                        Object Oriented Design
  47. Green Oaks, Il 60048 (708) 918-1004       C++
  48.