Named constants

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
(New page: A Named Constant is a descriptive, meaningful name, not a literal, that is given to take the place of a number, string or other expression. It is similar to a variable, but cannot be modif...)
 
Line 1: Line 1:
A Named Constant is a descriptive, meaningful name, not a literal, that is given to take the place of a number, string or other expression. It is similar to a variable, but cannot be modified. It has a global scope.  
+
A Named Constant is a descriptive, meaningful, non literal name that is given to take the place of a number, string or other expression. It is similar to a variable, but cannot be modified. It has a global scope.  
  
 
Named Constants should be used for values that occur in many places in the code. This allows you to easily change the value by changing the constant definition instead of changing the value in each place.
 
Named Constants should be used for values that occur in many places in the code. This allows you to easily change the value by changing the constant definition instead of changing the value in each place.
  
 
This improves the readability of the code, and makes it way easier to maintain.
 
This improves the readability of the code, and makes it way easier to maintain.

Revision as of 04:07, 4 October 2008

A Named Constant is a descriptive, meaningful, non literal name that is given to take the place of a number, string or other expression. It is similar to a variable, but cannot be modified. It has a global scope.

Named Constants should be used for values that occur in many places in the code. This allows you to easily change the value by changing the constant definition instead of changing the value in each place.

This improves the readability of the code, and makes it way easier to maintain.

Personal tools