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

  1. Path: sparky!uunet!pmafire!news.dell.com!swrinde!elroy.jpl.nasa.gov!ames!pacbell.com!UB.com!igor!thor!rmartin
  2. From: rmartin@thor.Rational.COM (Bob Martin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: GOTO, was: Tiny proposal for na
  5. Message-ID: <rmartin.715447981@thor>
  6. Date: 2 Sep 92 15:33:01 GMT
  7. References: <714668024@thor> <6800007@tisdec.tis.tandy.com> <rmartin.714863091@thor> <2318@devnull.mpd.tandem.com> <rmartin.715001372@thor> <4192@papaya.bbn.com>
  8. Sender: news@Rational.COM
  9. Lines: 47
  10.  
  11. cbarber@bbn.com (Chris Barber) writes:
  12.  
  13. |Well I must admit that it seems that most people posting on this topic
  14. |say that they do not use gotos, even those who disagree with you. So I
  15. |guess I will just have to come out of the closet and admit that I have
  16. |been using them for several years and with no regrets. I can't recall 
  17. |finding any bugs that were related to my use of gotos and I haven't heard
  18. |any complaints about the readability of my code. In fact, I resent your
  19. |implication that because I use gotos I am lazy and write unstructured
  20. |code. 
  21.  
  22. Code which uses gotos in a manner which is inconsistent with one of
  23. the 3 control structures of structured programming is not structured.
  24. This does not mean that it doesn't have a structure, of course it
  25. does.  But it does mean that it is not "structured" according to the
  26. tenets of SP.
  27.  
  28. Are you lazy?  I doubt it.  But you have decided to ignore some of the
  29. lessons of the past.  
  30.  
  31. [traditional example of error processing eliminated]
  32.  
  33. There are lots of ways of using gotos which appear relatively benign,
  34. perfectly safe, easy to read, easy to maintain ... at least to the
  35. author.  And, if he gets no complaints, then perhaps he was right.  Or
  36. perhaps he was wrong.  Absence of complaint is not a mandate.
  37.  
  38. Before "Structured Programming", we all used gotos.  And not all our
  39. programs were maintenance monsters.  Many were quite elegant, well
  40. thought out, flexible and robust.  So what?
  41.  
  42. We have since learned that writing algorithms that conform to the
  43. principles of structured programming can enhance the robustness and
  44. maintainability of the code.  When you violate those principles, you
  45. take a needless risk.  You may be satisfied that the risk was worth
  46. it, but so what?  You aren't the only one who will be responsible for
  47. your code.  Others will come after, and have to work through the same
  48. reasoning that you did to assure themelves that your "way" is safe.
  49.  
  50.  
  51.  
  52.  
  53. --
  54. Robert Martin                        Training courses offered in:
  55. R. C. M. Consulting                       Object Oriented Analysis
  56. 2080 Cranbrook Rd.                        Object Oriented Design
  57. Green Oaks, Il 60048 (708) 918-1004       C++
  58.