Use Named Constants to Write Clearer Code
August 18, 2004 Ted Holt
You’d expect experienced programmers to know and use techniques that less experienced programmers might not know. But even programmers with little experience know how to define named constants in one or more languages, although they may not know how to use them effectively. Yet named constants can contribute so much to program clarity, as I wish to show you now. I use RPG IV to illustrate, since that’s the language I use most often, but the principles apply to any language that supports named constants.
THE PROBLEM WITH LITERALS
The purpose of named constants is to avoid using literals, a