Still a magic number?
Friday, August 26th, 2005So Sam and I were programming today, and we found a place in the code where we were using a magic number. Something along the lines of:
function TMyObject.IsEditable: Boolean; begin Result := obj.IsEditable(1); end;
Wanting to replace the magic number with a meaninful symbolic constant, we looked around for what the magic number could represent. After failing to find what exactly the magic number meant, and not wanting to leave a magic number in the code, we replaced it with our own meaningful constant. The code now looks more like this:
function TMyObject.IsEditable: Boolean; const MagicNumber = 1; begin Result := obj.IsEditable(MagicNumber); end;
So, if we replace a magic number with a poorly named constant, is it still considered a magic number?