I also have found it helpful over the years to learn that many of the classic examples of "Magic Numbers" have their own domain-specific static values within utility classes in the standard library or a readily-available third-party library (like Apache Commons). A few examples:
@scottshipp Great points! Thanks for the examples!
Standard and third-party libraries might have common values (like the ones you mentioned). The cool thing with my example is that you can customize them yourself since a library won't know less common values (such as an address).
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I also have found it helpful over the years to learn that many of the classic examples of "Magic Numbers" have their own domain-specific static values within utility classes in the standard library or a readily-available third-party library (like Apache Commons). A few examples:
Measuring time
Common numbers found in math
Calculating file size
Much of the time hard-coded math can be replaced with these utilities. For example, instead of calculating five minutes in milliseconds like:
or (only slightly more comprehensible)
Do it this way instead:
@scottshipp Great points! Thanks for the examples!
Standard and third-party libraries might have common values (like the ones you mentioned). The cool thing with my example is that you can customize them yourself since a library won't know less common values (such as an address).