Article View: comp.lang.misc
Article #2706Names for everything
From: Erland Sommarskog
Date: Sat, 12 Jan 1991 19:39
Date: Sat, 12 Jan 1991 19:39
30 lines
1492 bytes
1492 bytes
Also sprach Dr A. N. Walker (anw@maths.nott.ac.uk):
>Really? Do you write
>
> #define ONE 1
> #define TWO 2
> #define TWENTYFOUR 24
> #define SIXTY 60
> secs = (((days*TWENTYFOUR + hours)*SIXTY + minutes)*SIXTY + seconds;
> for (j = ONE; ; j += TWO) ...; /* step through odd integers */
Which reminds of how often I swore over my project colleagues
on my previous contract. Often you would find declarations like
CONST space = ' ';
percent = '%';
which I usually removed and replaced every occurence of the constant
with the literal. The name of a constant should reflect the meaning
of the constant, not the contents. I don't know from where these
people had acquired bad habits, but this an information-system place
so Cobol inheritance is suspected.
However they are not alone. In "C++ primer", Stanley B. Lippman
has the following declaration on page 93:
enum Vowels { a='a', e='e', i='i', o='o', u='u' };
--
Erland Sommarskog - ENEA Data, Stockholm - sommar@enea.se
"There is only one success -- to be able to spend your life in your own way"
Christopher Morely
Technical Details
Message-ID:
<2389@enea.se>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!enea!sommarReferences:
<1991Jan8.165344.13870@maths.nott.ac.uk>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!enea!sommar From: sommar@enea.se (Erland Sommarskog) Newsgroups: comp.lang.misc Subject: Names for everything Message-ID: <2389@enea.se> Date: 12 Jan 91 19:39:03 GMT References: <1991Jan8.165344.13870@maths.nott.ac.uk> Organization: Enea Data AB, Sweden Lines: 30