home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!sun-barr!ames!pacbell.com!UB.com!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.715102882@thor>
- Date: 29 Aug 92 15:41:22 GMT
- References: <714668024@thor> <6800007@tisdec.tis.tandy.com> <1992Aug26.130335.26725@hemlock.cray.com> <1992Aug26.194538.1598@spss.com> <rmartin.714931485@thor> <1992Aug27.181013.29933@spss.com>
- Sender: news@Rational.COM
- Lines: 47
-
- hosken@spss.com (Bill Hosken) writes:
-
- >The rule "avoid goto" does not stop anyone from writing confusing
- >code. It probably makes some people think more about the code
- >they write when seeking alternatives to the goto, but taken alone
- >it does little good.
-
- I don't agree. Taken alone, it forces your code to have a "known"
- structure. This doesn't mean that the code is "good code", it just
- means that there are some basic rules that the reader/maintainer can
- depend upon. This have significant value.
-
- >A better rule would be "Be prepared to give a clear and convincing
- >argument that the code is correct".
-
- But what is "correct code"? Code that works? I can write code that
- works, but is unmaintainable. If all we want to produce is "code that
- works", then the nightmares which have plagued us from the late
- sixties on are sure to continue.
-
- What we want is:
-
- Code that works.
- Code that is maintainable.
- Code that is reusable.
-
- Each of these three aspects requires thought and effort on the part
- of the designer. Moreover, the easiest of the three tasks, is the
- first. Any high school comp-sci geek can cajole a bunch of program
- statements into working. But to write code which others can
- understand and eaily alter, or which others can re-use in a different
- context takes thought, planning and work.
-
- Now, there are some rules which we have learned over the years which
- help this process. One of them is "don't use gotos", another is "use
- single-entry, single-exit constructs". If we follow these rules, then
- we can concentrate on the job at hand, i.e. the correctness,
- maintainability and reusability of our code. But if we ignore those
- rules, then we add more variables to the problem we are trying to
- solve. And if we break the rules, and provide justifications, then we
- have expended effort in the wrong direction.
-
- --
- 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++
-