Monday, June 8, 2015

Make hard coding your default choice

http://enterprisecraftsmanship.com/2015/06/08/make-hard-coding-your-default-choice/

To my experiences, I divide this kind of  "magic number" into three categories:

#1 Very small chance to change: Hard coding
#2 Good chance to change in the future:
  Hard coding with default value but checking config file first
string ConfigSetting_SMTP_host = ConfigurationManager.AppSettings["SMTP_host"] ?? "google.com";

#3 For sure change (such as dev vs product environment): read from config file directly