You've already got the answer you wanted, but an amusing (to me and one workmate at least, although not amusing to another) example may be appreciated.
A workmate and I were working through refactoring and understanding some code (C++, but not really relevant to the story) that another workmate had written. The code concerned used circular buffers at the end of a calculation chain for feeding samples into a digital to analog converter. Getting the size of the buffer right is a critical part of making the system work correctly. We encountered a few lines that were used to configure the buffers and looked something like:
mOutBuffer = CreateBuffer(baseBufferSize+3*2*k10HzKneeSampleBufferSize +);
We couldn't figure out what the 3 * 2 was doing in there and there were no comments to give any clue so we changed it to:
#define PI 3.1415 // Circular buffers mOutBuffer = CreateBuffer(baseBufferSize + 2 * PI * k10HzKneeSampleBuf +ferSize);
which we at least thought amusing. We hoped that the other workmate would appreciate the joke then provide some sort of sensible name for the constant and perhaps a useful comment. Instead, at the next scrum he noted that someone had added a PI constant "probably they thought it was amusing" and it wasn't right!
Sadly the PI constant is still in the code and we still don't really know why that particular value is used. There was no doubt a clue in the value being written as 3 * 2, but it escaped us.
So, that's a classic magic number. It's critical to correct operation of the code, but provides not obvious rational for its selection.
And if you read a little friction in the team between the lines, you are right. The person who wrote that part of the code is very bright, but I think he has trouble appreciating that not everyone understands stuff in the way he does.
In reply to Re^3: Perl vs Python revisited
by GrandFather
in thread Perl vs Python revisited
by QuillMeantTen
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |