Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site mmintl.UUCP Path: utzoo!linus!philabs!pwa-b!mmintl!franka From: franka@mmintl.UUCP (Frank Adams) Newsgroups: net.lang.c Subject: Re: Use of i++; Re: C programming style (actually commenting) Message-ID: <505@mmintl.UUCP> Date: Fri, 19-Jul-85 14:21:32 EDT Article-I.D.: mmintl.505 Posted: Fri Jul 19 14:21:32 1985 Date-Received: Wed, 24-Jul-85 05:40:51 EDT References: <11434@brl-tgr.ARPA> <508@oliveb.UUCP> Reply-To: franka@mmintl.UUCP (Frank Adams) Organization: Multimate International, E. Hartford, CT Lines: 32 Summary: comment sections In article <508@oliveb.UUCP> jerry@oliveb.UUCP (Jerry Aguirre) writes: >If you want ease of maintenance then concentrate on USEFUL comments. My >favorate non-comment is: > int debug; /* true if debugging is enabled */ >or the ever popular: > i++; /* increment i */ > >Usually followed by a 3 page procedure with a cryptic name and no >comments. I mean is it really hard to figure out what the variable >debug is used for? I would really rather have a few lines at the top >of each procedure telling what it does and what the arguments are. It >is usually easy to follow the code if you know why the procedure was >called. It's trying to follow the code when you don't know what it was >called for or what its inputs are that is hard. Broadly speaking, I agree with this. But you should go a step further, (especially for a 3+ page procedure) and put a comment at the top of each logical section of the code. This makes it easier to read the code and figure out what the program does. A comment on each line doesn't (much) do this, because one can as easily read the code as the comments. Only obscure statements need comments, which is why one puts a comment on every line in assembler code. (! :-) >Languages don't write bad code, people do. Yes, but some languages make it easy to write good code, and hard to write bad code, while others do the opposite. > Jerry Aguirre @ Olivetti ATC >{hplabs|fortune|idi|ihnp4|tolerant|allegra|tymix}!oliveb!jerry Frank Adams