Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!ateng!chip From: chip@ateng.com (Chip Salzenberg) Newsgroups: comp.lang.c Subject: Re: A question of style Message-ID: <25855765.1878@ateng.com> Date: 12 Dec 89 19:54:12 GMT References: <1989Nov23.170838.10376@phri.nyu.edu> <680014@hpmwjaa.HP.COM> <257E97F4.24962@ateng.com> <594@s5.Morgan.COM> Organization: A T Engineering, Tampa, FL Lines: 34 According to amull@Morgan.COM (Andrew P. Mullhaupt): >According to chip@ateng.com (Chip Salzenberg): >> The general rule I adhere to most strictly is: "Repetition is evil." >> The expression "c=getchar(), c!=EOF" is harder to read than >> "(c = getchar()) != EOF" for [this] reason. > >Isn't it possible that in some places repetition can increase >readability? Of course. Any style rule, taken to the extreme, can be counterproductive. But elimination of redundancy leads automatically to several good programming practices, especially factoring. True, readability is only one issue. But small-scale and large-scale readability are sometimes at odds. For example, if you write a program that consists entirely of simple, understandable modules, that's fine; but if the functions of the program are factored badly enough, the source will be too big to understand, and will therefore be unreadable on the large scale. I think that the best measure of readability is not lines of code per unit time, but percentage of program per unit time. If a routine takes ten minutes to understand, that's bad; but if that routine is one tenth of the program, things are looking up. >I'd rather break some expressions into more than one part just to keep >the lid on the complexity, even if I need to see the same thing twice >in a row. Actually, the creation of temporary variables is a classic way to eliminate repetition in program code. I constantly use them that way myself. -- You may redistribute this article only to those who may freely do likewise. Chip Salzenberg at A T Engineering; or "The Usenet, in a very real sense, does not exist."