in reply to Re^2: Perl vs Python revisited
in thread Perl vs Python revisited
I don't see a huge benefit in nailing down a precise definition of what is, and what is not, a magic number. We don't have hard and fast rules about magic numbers at work. Zero and one, for example, will usually survive a code review (though perhaps not if used with bools). There is room for common sense, negotiation and programmer discretion. The focus is on simplicity, clarity and maintainability.
For example, a magic number like 7.4269 that may change in the future being sprinkled all over the place would not survive the review; you'd be asked to choose a meaningful name for it, $customer_interest_rate for example. Even if the number is PI, and so won't ever change, the code will usually be clearer if you use $pi rather than 3.14159.
To be honest, I don't feel strongly about magic numbers and can't ever remember them being a big issue during a code review. There are bigger fish to fry, things like:
Obligatory references:
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Perl vs Python revisited
by BrowserUk (Patriarch) on Jan 07, 2017 at 19:17 UTC | |
by eyepopslikeamosquito (Archbishop) on Jan 07, 2017 at 21:18 UTC | |
by BrowserUk (Patriarch) on Jan 07, 2017 at 21:27 UTC | |
by jdporter (Paladin) on Jan 09, 2017 at 21:28 UTC | |
by LanX (Saint) on Jan 07, 2017 at 21:50 UTC | |
A reply falls below the community's threshold of quality. You may see it by logging in. |