3 ms·
> To be fair, one of the most vocal advocates of higher code quality is Carmack His code is full of these antipatterns! One concrete example - magic numbers i
by chrisseaton 7y ago
> To be fair, one of the most vocal advocates of higher code quality is Carmack
His code is full of these antipatterns!
One concrete example - magic numbers in Quake.
https://github.com/id-Software/Quake/blob/bf4ac424ce754894ac8f1dae6a3981954bc9852d/QW/client/view.c#L135 https://github.com/id-Software/Quake/blob/bf4ac424ce754894ac...
Doesn't seem to cause him any problems in achieving success.
- klyrs 7y agoThat's a weighed average with, presumably, hand-chosen coefficients to make a nice visual effect. I fail to see how these numbers are "magic." How would you produce this effect without numbers?
- chrisseaton 7y ago> How would you produce this effect without numbers? That's not what 'magic numbers' means. The idea is that you factor out the number into named variables so they don't appear unnamed in the body of expressions.
- klyrs 7y agoOk, sure. Even so, this is about the least compelling example of "magic number" that I've seen. They're used once, the intent is clear, and you don't have to go hunting for the definition.