Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!nosc!ucsd!rutgers!gatech!bloom-beacon!bu-cs!buengc!art From: art@buengc.BU.EDU (A. R. Thompson) Newsgroups: comp.lang.pascal Subject: Re: Re: Comment Pollution Message-ID: <962@buengc.BU.EDU> Date: 30 Aug 88 21:01:11 GMT References: <6508@uwmcsd1.UUCP> <840@buengc.BU.EDU> <3987@freja.dk> Reply-To: art@buengc.bu.edu (A. R. Thompson) Followup-To: comp.lang.pascal Organization: Boston Univ. Col. of Eng. Lines: 43 In article <3987@freja.dk> stuf@freja.dk (Kristoffer H. Holm) writes: >In article <840@buengc.BU.EDU> art@buengc.BU.EDU (A. R. Thompson) writes: >>... >>we modified an existing compiler. There was a boolean variable spelled >>"ttyinuse". Upon reading the code we discovered that when the variable >>"ttyinuse" was true the tty was NOT in use! >>I'm not arguing in favor of excessive comments. I am however saying that >>assigning "meaningful" spellings to identifiers can be very tricky. > >Why, it should have been named tty_not_in_use (or TtyNotInUse if you prefer >that)! In my opinion, properly written Pascal programs only need >intensional comments, stating the purpose of chunks of code -- the primary >purpose of comments is to allow the reader/maintenance programmer to SKIP >code that is irrelevant to him/her! In the example a comment would have >done no good (especially not a misleading one)! My point was, and is, that assigning "meaningful" spellings to identifiers can be misleading. Sometimes we think that the spelling is actually denoting the meaning when in reality its meaning is only valid in the context of the programming language. > >>This allows you to change the counter range by changing only the value of >>a constant and buys you the advantages of named types. > >In general I don't agree: you use the wrong principle. Constants and >Types shall only be named if they can be misunderstood, or are used in >more than one place. And it is OK to have the constants 0 and 1 in ranges. >Otherwise you commit a sin similar to over-commenting, and use to many >different names. In the above example, > > type string_index = 1..whatever; > var r: stringindex; > >is more readable---note that "string_index" is a better type name than >"counterrange": it shows the intension of the type, not its applications! >Of course, "r" should be called something else (not apparent from the >example). This is wholly a matter of style. The caveat of only naming constants etc if they are subject to use in more than one place assumes the program will not be modified in the future to require such multiple usage. Again, it's really a matter of style, it's just that I make it a habit to use such a style which gives me, I claim, more flexibility at low cost.