views:

46

answers:

1

Hello, currently in our application we have an ApplicationConfiguration class. It is basically just a static class with const values specifying certain application-global configuration options. Some of these values will rarely if ever change and are only put into the configuration for elegance/cleanness.

Some of these values though do need to be different between production and development. So I'm considering making this class just a wrapper over Web.config. These values are checked many times throughout our codebase. If I change these from a const to a read-only getter that reads from Web.config will this affect compiler optimizations or make our application in any way slower?

+1  A: 

Web.config values are read into memory once in app start, and are held there until the app ends. So, there's no real difference in performance here -- no extra file I/O repeatedly reading web.config.

One key difference between the two approaches happens when you need to change the value of one of the configuration options. Changing the value in web.config is relatively easy and may not even require a restart of the application (depends upon how it's configured).

To change the value of a constant, of course, you have to recompile and redeploy your code. That may not be a trivial endeavor.

DOK
redeploying is really not a problem for us. We can do a full redeploy in in about 20-30 minutes and our application is only used by certain people during US working hours(8am-6pm or so) so we have time where we can take the application offline even. That's not a problem.
Earlz
That's 20-30 minutes compared to <30 seconds to change the web.config, plus the harzard of doing one of deploy steps incorrectly. But that's production - perhaps a new release (i.e. deploy) is required for any change.
Lachlan
Well, the only thing you have to do instead for such a change is reupload the website's assembly file which takes about 15 seconds for me in FireFTP.
Earlz
@Lachlan see above
Earlz
Ok, so the point here is that in general the performance between the two options is negligible, but ease and reliability of deployment is a different consideration. I think the question that we're touching on is how to decide whether a particular value should be a constant or a config setting. I'm hesitant to make any blanket statements, but one possible rule of thumb is that if a value is internal to the application, then it's fine as a constant; if it relates to an external resource (e.g. database connection string), then it's better as a config setting.
Dr. Wily's Apprentice