Path: utzoo!mnetor!uunet!nuchat!sugar!peter From: peter@sugar.UUCP (Peter da Silva) Newsgroups: comp.lang.misc Subject: Re: Readable names Message-ID: <1757@sugar.UUCP> Date: 25 Mar 88 12:33:17 GMT References: <2318@bsu-cs.UUCP> <2835@enea.se> <1810@sics.se> <25548@cca.CCA.COM> <2857@enea.se> Organization: Sugar Land UNIX - Houston, TX Lines: 43 Summary: Memorable names In article <2857@enea.se>, sommar@enea.se (Erland Sommarskog) writes: > Richard Harter (g-rh@CCA.CCA.COM.UUCP) writes: > >Just a note -- it is my experience that long (readable) identifier names > >should not be used.... > >I.e. you have to remember, at each writing, the > >exact words used in the name. This is not a readability argument. This is a memorability argument. In any large program you're not going to remember the meanings of all your variables without either finding the context they're used in, or popping back up to where they're declared and reading your comments. Long, short, and fancy variable names don't help much in writing the code. Long names do help a lot in reading the code. > But if you mean to imply that NumOfAcc would be better than > NumberOfAccidents, I have to object. NumOfAcc is harder to remember, > since I have to remember the exact abbreviation too. (Your first argument > may still be valid, though. Particulary if it is a freqeuntly used name.) Gee, what did I call the accident count? AccidentCount? NumberOfAccidents? CrashAndBurn? Um... If you're going to be reading code more than writing it, long variable names are a win. If you're going to be writing more code (say, it's APL or a command language), short ones are a win. If you ever used VAX/VMS, and can't remember whether you get the file sizes with a DIR/LENGTH or a DIR/SIZE or whatever, you'll know what I mean. (I'm surprised they didn't make that "SHOW FILES" -- everything else in the system seems to be an option on SHOW). Frequently used names should be short: you're not going to forget "mv" or "rm", but a lot of people can't remember whether to use "fsck" or "fsdb". (Speaking of which, I think doubling the size of every directory on the system wouldn't be too high a price to pay for 30 character file names in UNIX). > As a whole, choosing names that are easy to remember and to understand > is not always that easy. You win a No-Prize for the understatement of the year! -- -- Peter da Silva `-_-' ...!hoptoad!academ!uhnix1!sugar!peter -- Disclaimer: These U aren't mere opinions... these are *values*.