Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions

  




 

 

3.8. Constant Variables

A good rule to follow is to never use numbers other than 1 and 0 in your code. If you require another numeric constant you should make it a const variable; this way it gets a nice meaningful name. The number 40 has little meaning, however, the identifier HOURS_WORKED_PER_WEEK tells us something about what a function is doing. Another benefit is that you can change the value of a const variable in one place rather than having to change all occurrences of 40. Using the latter method it is easy to make a mistake by changing an unrelated occurrence of 40 or forgetting to change an occurrence.

 
 
  Published under the terms of the GNU General Public License Design by Interspire