Constants

Learn why it is a good practice to declare your constants in a single place.

Why declare constants?

A single place to declare constants is good, as there is no need to type the same value in a program repeatedly. Plus, it helps in avoiding the mystifying Magic NumbersA magic number is the direct usage of a number in code. Since it has the chance of changing at a later stage, we can say that the number is hard to update. It is not recommended and is considered to be a breakage of one of the oldest rules of programming. problem.

Get hands-on with 1400+ tech skills courses.