why are magic numbers preferred?

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn at axis.com
Wed Apr 16 20:05:04 UTC 2008


On Wed, 16 Apr 2008, Denys Vlasenko wrote:

> On Wednesday 16 April 2008 18:33, Paul Smith wrote:
> > On Wed, 2008-04-16 at 17:59 +0200, Cristian Ionescu-Idbohrn wrote:
> > > Please consider the 1st attachment as a POC, and then the 2nd
> > > attachment, which is more dearer to me ;-)
> >
> > ???
> >
> > > +#define FIVETWELVE 512
> >
> > How is using "FIVETWELVE" any better than "512"?  It doesn't provide
> > ANY abstraction at all.  If you decide you need a different size are
> > you going to set "#define FIVETWELVE 1024"???  Heaven help us.
>
> I believe that was a joke.

Yes, maybe not the best ;-)
Still, changing a controlling magic number defined in one place _must_
be slightly easier than doing it in fivehundred and eleven places ;-)


Cheers,

-- 
Cristian



More information about the busybox mailing list