Request Dev Services »

cdev.co / Notes /

Benefits of using ‘constants’ over ‘variables’ in programming?

Do programmers prefer to use constants or variables?

Constants would be a more stable choice for variables that aren’t meant to be changed later down the line. The siue.edu website describes them as;

“Constants are similar to variables – constants are values that are stored to memory locations; however, a constant cannot have its value change during program execution – constant values are generally fixed over time.”

Because of this another benefit of using constants over variables is performance, it saves on memory and alas speed. It is also said to be a ‘safer‘ choice and a more ‘clean‘ option to evade typos while encapsulating arbitrary data in legacy systems elegantly and progressively. So, as a programmer we’d probably prefer to use constants as opposed to ever changing variables that ripple through the code with every change; and if constants are lighter on speed and memory then that is always a great plus.

 

 

Extra useful info on the topic in the below articles:

About the Author
Cameron Cashwell Web Developer
I build websites, web apps, and software. Wanna work together? Let's chat about your project!

Leave a Reply

Be the First to Comment!

Notify of
avatar