We're all aware that magic numbers (hard-coded values) can wreak havoc in your program, especially when it's time to modify a section of code that has no comments, but where do you draw the line?
For instance, if you have a function that calculates the number of seconds between two days, do you replace
seconds = num_days * 24 * 60 * 60
with
seconds = num_days * HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE
At what point do you decide that it is completely obvious what the hard-coded value means and leave it alone?
seconds = CALC_SECONDS(num_days);
– FrustratedWithFormsDesigner Mar 9 '11 at 16:31TimeSpan.FromDays(numDays).Seconds;
– Nobody Mar 9 '11 at 16:34HOURS_PER_DAY will never need to be altered
), you'll never be coding for software deployed on Mars. :P – FrustratedWithFormsDesigner Mar 9 '11 at 18:29