I have been learning about programming for years. More recently, I have been taught that magic numbers or constants should not be hard coded deep in your program. Doing a search for constants magic numbers really only gave me this. Since joining this site I have seen/read about some examples of less than desirable code.
An example would be that you need PI in your code and you need it to a specific decimal place, 3.1415.
Less desirable practice:
wheelDiameter = 2 * radius * 3.1415
...more code
circumference = 2 * circleRadius * 3.1415
More desirable practice
'near beginning of code
PI = 3.1415
wheelDiameter = 2 * radius * PI
...more code
circumference = 2 * circleRadius * PI
With the more desirable practice, if you change your mind on how exact PI needs to be you change the variable/constant in one place and all of your code uses the new number. Otherwise, you must sift through your code and replace every instance with the correct number, correct meaning that if your code is large enough you might miss a replacement or mistype the number.
Another example would be line following. Say you have 3 sensors and they give you a 1 when the sensor is over a white stripe.
Less desirable:
if (sensor1 == 1 and sensor 2 == 1) then veer left;
More desirable:
left = 0b100 'binary representation of sensors white on black
'left = 0b011 'black on white
leftCenter = 0b110
... more code
if leftCenter then veer left;
Now, if the conditions change and you are instead looking for a black line on a white background you need only change a batch of constants at or near the beginning of your program. You could even code them in as remarks.
I hope this helps someone. I will accept any and all criticism.