Friday, March 27, 2009

When to put data into the data base vs. into a config file

It all depends? some of my rules of thumb are

for going into a config/resource file

  1. it's the same for every user, like the path to an image directory
  2. the data is only needed at the UI level and will not change very often, like a list of US States
  3. it may vary from server to server, like a resource URL for production vs testing

for going into a DB

  1. It changes per user or is user specific data
  2. it may need to be maintained by someone out side your development group
  3. It's going to be used outside of the UI layer
  4. it's going to be updated regularly

what ever you do

DON'T HARD CODE STRING INTO YOUR CODE, I don't care how positive you are that the bug report notify Email address will not change, DO NOT HARD CODE IT!!!! or 3 years down the road what would have been a 2 sec config change will result in 2 weeks of work to get an out dated legacy piece of crap application to compile!! or another fun one was an xml-schema hard coded into an application with

stringname += "Schema data";
+= "Schema data";
+= "Schema data";

Oddly enough same guy, go figure.

No comments: