4 ms·
Right, but your window size example would be a case of using the same value in more than one place, so it would be better as a named constant. Actually, the wh
by s_tec 11y ago
Right, but your window size example would be a case of using the same value in more than one place, so it would be better as a named constant.
Actually, the whole example smells ripe for refactoring. Where are there multiple windows throughout the app all sharing a default starting size? Sounds like it's time for a base class or something. Once you've eliminated the redundant sizing code, you will find that your default size values now exist in only one place (the base class). Since they are only in one place, you can write them as numbers again instead of named constants.
I've played this pattern out more times than I can count. The problem isn't magic values sprinkled through the code; it's having redundant code in the first place. Once you solve that, the magic numbers tend to evaporate.