Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!purdue!i.cc.purdue.edu!j.cc.purdue.edu!pur-ee!uiucdcs!uiucdcsb!friedman From: friedman@uiucdcsb.cs.uiuc.edu Newsgroups: comp.lang.c Subject: Re: How do you explain the obvious? Message-ID: <165600049@uiucdcsb> Date: 28 Apr 88 14:22:00 GMT References: <1738@loral.UUCP> Lines: 29 Nf-ID: #R:loral.UUCP:1738:uiucdcsb:165600049:000:1403 Nf-From: uiucdcsb.cs.uiuc.edu!friedman Apr 28 09:22:00 1988 Jim Harkins (jlh@loral.UUCP) writes: > I seem to have inherited a program that is, ahem, not in good shape. > For example, there was a '#define OK 0' at the top of the code, and > some of the routines actually used it. BUT, in addition to OK, it used 0, > FALSE, and NULL used interchangeably! I couldn't believe it! > I mentioned that this was not a good thing to do and the response was "Why > not? I know it's 0 because I set it to 0!". I'm stumped. To me the > answer is so obvious I can't think of anything better than "because". > So what do I tell this person? Tell the person: (1) It's bad because it's confusing to read due to the inconsistency. You aren't writing just for the compiler's benefit, but for the humans who come after you and have to read and understand the program and modify it. (2) It's bad because, in the rare circumstance that one wanted to change the value of "OK", one might reasonably expect to change the one #define and presume that would get the job done. The inconsistent usage would destroy that reasonable expectation. H. George Friedman, Jr. Department of Computer Science University of Illinois at Urbana-Champaign 1304 West Springfield Avenue Urbana, Illinois 61801 USENET: ...!{pur-ee,ihnp4,convex}!uiucdcs!friedman CSNET: friedman@a.cs.uiuc.edu ARPA: friedman@a.cs.uiuc.edu