Magic Numbers in the Code
When you write a code and somewhere down the line, you are using an arithmetic constant like PI, have it defined as some readOnly constant string and use the string instead of hardbinding the number value in the code. There are good advantages of avoiding magic numbers in the code:
- Isolating the magic numbers into a single place labeling them with a variable would help in adjusting the precision value later.
- The code appears cleaner and neater without beguile numbers spread across the code and confuse a new person maintaining your code.
- Troubleshooting problems because of values to these constants is easy.