My application configuration is very hierarchical and fits nicely into a single XML. Soon (YAGNI, Yeh) parts of this information will be consumed by other applications remotely, which calls for a database.
So, I went into designing DB tables and mapping them back to my application's class hierarchy (using EF). however it became a maintenance nightmare.
I'd love to hear from others experience considering this issue, thanks.
We had very good experience with storing the config in a database for long running applications (like web sites and services). Advantages:
select max(lmod) from config
) automatically or by a signal (ping a web page or create an empty file somewhere)The main problem is the editing if you have a complex, hierarchical config structure with defaults, lists and inheritance. Our solutions:
Config objects hide these details, so the application just works with objects.
A special class is responsible for re-reading the config in case of a change. Usually, we update the config some time during the day and a timed job will reload it after hours. This way, we never need to synchronize the config methods.
Backup and change history were a problem, though. We fixed that by using XML files in the VCS which are then "uploaded" to the DB. This way, we could verify the production config before uploading it (by using it with a special set of unit tests on a developer machine). When it got activated during the night, it usually worked right away and the operator responsible for the app would just have to do a little bit of testing.
IMHO config should live in files, files work well for people and they're ok for computers. DBs work well for big data, but they're overkill for human stuff. The two are normally mutually exclusive, and when you do try to combine them you get something like the registry - uggh.
Why not leave the config in a file, and build a DAL and service layer around it so that your apps can use it. That assumes you can host onto a central server, if not have multiple copies of the file in the wild.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With