constants

concepts
CONCEPT
       symbolic constants

UPDATE
       Mateese, 18-Jun-1993, 22:30 MET

DESCRIPTION
       Symbolic constants are a neat way to make programs readable as
       well as updateable and typing-error proof.

       A symbolic constant is specified in LPC using a preprocessor
       define:

         #define MAX_SUNBRIGHT  100

       would define the value of the maximal sunbright to be 100.
       Thematically linked constants are collected in include files
       (MAX_SUNBRIGHT actually is defined in /sys/config.h).

       Programs can now use the constants by including the containing
       files: to use MAX_SUNBRIGHT, a program would have to include
       /sys/config.h with the statement

         #include <config.h>

       and could then write 'MAX_SUNBRIGHT' instead of '100'.

       The advantage of doing so is threefold.
       First, the program is easier to read (a '100' may have a lot of
         meanings, but a 'MAX_SUNBRIGHT' has only one).
       Second, changes in the symbolic constants are transparent: the
         using programs won't cease to work. E.g. if someday the value
         of MAX_SUNBRIGHT should be doubled for some reason, all programs
         using the symbolic constant will continue to work, but all which
         use the then-outdated '100' won't function properly and will need
         to be updated.
         And since in most of such cases the creating wizard is no longer
         active, the programs are likely to be scrapped... and do YOU want
         to see your creations vanish just because of one value?
       Third, typing errors in the name of the constant are immediately flagged
         by the gamedriver, whereas typing errors in the constant are hard
	 to discover.
       
       In a nutshell: if there is a symbolic constant for something, USE IT!

       The few keystrokes more when writing the program will save a lot of
       work and tears later.

SEE ALSO
       Any good book about the Art of Programming (even those by St. Niklaus).