Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Home » Tip Bank » C++
Language: C++
Expertise: All
Jun 25, 2001

Dynamic Constants


In applications that cannot be recompiled (e.g., apps that are installed on a customer's machine as binaries only), values of constants may change occasionally. For example, exchange rates and the local sales tax rate are constants whose values are subjected to change. Using compile time constants for such values may cause maintenance problems. Consider:
 
const double SALES_TAX =5.0; // not recommended.

Imagine what would happen if the local sales tax was raised or lowered. The user wouldn't be able to modify the code and recompile the application. A better solution is to use a dynamic constant. A dynamic constant is a variable whose value is read from an external source, say a database table, an environment variable, a file, or a Web page at program's startup. This value remains fixed until the application exits. Once the application executes again, it will read the updated values of these dynamic constants.
Danny Kalev
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date