5 ms·
I think defining the constant the first time you use it (if you're assuming you might only use it once) may be a reasonable solution to this, but if you plan on
by Roodgorf 11y ago
I think defining the constant the first time you use it (if you're assuming you might only use it once) may be a reasonable solution to this, but if you plan on anyone else to ever be looking at your code I feel like magic numbers should absolutely be attached to some sort of name.
If someone were working on a different section of code and came upon a place where they needed maxRetries, but there was only a 5 defined somewhere, how would they know that it was already used once? Defining constants for anything that may be used multiple times saves the time of knowing/combing through every other section of code that could have already defined it.