Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site dciem.UUCP Path: utzoo!dciem!ntt From: ntt@dciem.UUCP (Mark Brader) Newsgroups: net.lang Subject: Re: Superstition in Programmers Message-ID: <598@dciem.UUCP> Date: Wed, 4-Jan-84 17:47:24 EST Article-I.D.: dciem.598 Posted: Wed Jan 4 17:47:24 1984 Date-Received: Wed, 4-Jan-84 19:23:53 EST References: <322@decvax.UUCP> Organization: NTT Systems Inc., Toronto, Canada Lines: 28 Martin Minow (decvax!minow) writes: My favorite superstition (in my own programming) is to never use an equality test where a magnitude test could be used. For example: something(count) int count; { while (count > 0) { stuff(count); count--; } } ... Actually, this is not entirely a superstition. It's good insurance against a runaway program, if the count may be decremented in several places within the loop; then you don't have to make sure it will always hit 0 at the bottom of the loop. However, if the count is only decremented once at the bottom of the loop, then this code may be an example of two other superstitions: using while where for would be clearer, and counting downwards to 0 instead of upwards to how_many_times. In the spirit of "Software Tools", Mark Brader