Re:Three hundred programming interviews in thirty days
by mjfisher on Wednesday June 24, 2015 @02:50AM
(#9770051)
Good, I think? It wouldn't be a deal breaker at interview for me (or even something we test for, come to think of it), but they were right in that it is a magic number. Unless you are doing something where the context is so perfectly obvious that number should be an 8, it's better off tagged as a constant so the next dev to come along has a better chance of understanding your code.
[ Parent
| on HN ]
Re:Three hundred programming interviews in thirty days
by NickPollard on Wednesday June 24, 2015 @05:04AM
(#9770456)
Indeed:
static const int eight = 8;
x * eight;
Sometimes magic numbers are just that - numbers. Adding constant definitions is often a good thing, but sometimes just adds noise.