Lists Home |
Date Index |
- From: email@example.com
- To: firstname.lastname@example.org
- Date: Wed, 25 Feb 1998 19:58:22 -0700
> >The good programming practice of replacing "magic numbers" with
> >constants is even older than the structured programming movement, and any
> >programmer who writes
> But that's not really the point I don't think. The point isn't "if you are
> as macho a programmer as me you don't need any help".
This is a pretty silly representation of what I wrote.
> The point is that we
> work in a commercial environment and every single semantic that can be
> expressed in the code itself, so that the compiler can tell you when break
> them, is a Very Goode Thinge.
It is, of course, a question of degree. A little help from the compiler is
useful, but the compiler cannot hold a programmer's hand and make him adopt
every common-sense good practice. I happen to believe that interface
constants are simple enough to "get right" that it is unnecessary to introduce
complexity and slow performance with such schemes as singleton object
> It does no good at all to have a named constant if you can accidentally
> pass that named constant to 150 other things for which its not intended and
> the compiler cannot catch it. Its a fundamental lacking in Java that makes
> me shudder to think that people actually want to do serious work in it.
I don't see the disaster you are pointing out:
const unsigned int SUNNY_SIDE_UP = 1;
const unsigned int SCRAMBLED = 2;
const unsigned int POACHED = 3;
void process(in unsigned int processType);
const unsigned int A = 1;
const unsigned int B = 2;
const unsigned int C = 3;
void bar(in unsigned int param);
So as I write the code, I simply use the proper constants for the proper interface.
No quantum chromodynamics there.
Now why would I ever use a constant that was meant for the Egg interface in the context of Bar, even though Bar happens to have a constant of the same value? I wouldn't mix things up in even the above simple example, so it boggles my mind to think that anyone in their right mind would commit such folly 150 times. Is this the "machismo" to which you allude? I call it basic training, and no compiler or mechanism can prevent a project from the lack of same.
FourThought LLC, IT Consultants
Software engineering, project management, Intranets and Extranets
xml-dev: A list for W3C XML Developers. To post, mailto:email@example.com
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:firstname.lastname@example.org the following message;
To subscribe to the digests, mailto:email@example.com the following message;
List coordinator, Henry Rzepa (mailto:firstname.lastname@example.org)