4

For a CMS product/platform, what would be a maintainable and clear approach for editing and storing settings?

I'm not talking about technical (connstring, nh config, ...) settings, but settings that alter the behaviour of the product:

These settings are for example

  • Online Payment settings
  • Available parts and modules
  • Default behaviour of the application (showing details of list items by default, default landing page after certain actions)
  • ...

At this point we don't really have an approach, so the result is that all settings end up in the web.config.

This is probably not the best approach, since this is simply ending in an endless list of obscure key value pairs...

In this scenario we also cannot really anticipate to types (without codegen), so settings with checkboxes or predefined options... are hard to manage.

Another option would be to create the needed tables for each setting (type) and use that as a core setting system, but this will be harder to deploy and manage per customer.

I have lots of half answers to this question but not really a top down solution...

What I mean by top down:

  • Editing settings (admin screen)
  • Where to persist the settings
  • Loading the settings, without much hassle, but still in a maintainable way
  • Maintain/deploy customer specific settings

So options so far:

  • (web).config
  • .settings files
  • DB

But these are all kind of key-value approaches... Any other suggestions?

2
  • Once some opinions come in I'd also like to see how some people implement and access those settings in their MVC app. Static Settings class? Settings repository hooked up to Cache? Other options? Commented Oct 29, 2010 at 14:09
  • I found some very high level guidance on the subject in the P&P (apparchguide.codeplex.com), but the same concerns are listed there, not an actual guide for implementation. While I'm not looking for a silver bullet, there has to be some proven approach? Commented Oct 29, 2010 at 14:20

2 Answers 2

1

You could write a custom configuration section which allows you to store much more than key/value settings in the config file. This being said the config file is designed for read-only settings. If you need editing functionalities with admin screens then it would be best to use database. Storing this information in files is also a possibility but as this is a multi-threaded application you will need to properly synchronize access to those files which could quickly become cumbersome.

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks for the answer. Do you have any more guidelines for the DB option? Or would a section-key-value combination be sufficient?
As I said if you need to update those values frequently from your application a DB would be more appropriate.
Yes, I saw that, so the DB is certainly a more viable option. But in what DB structure would you save those values: section-key-value. Or would there be proven DB structures for this requirement?
key/value could be a table with two columns where the key is the primary key of the table and the second column contains the value.
Okay, I'm not asking how to create a key-value table, I'm asking if it's a good approach... For example, there's a checkbox and 2 options are dependant on that checkbox. Would you store that in a DB structure or just keep that logic in you code?
|
0

Basicly you can create Setting table. includes Name and Value fields. And you can store setting.

public class Setting : Entity
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Value { get; set; }
}

There will be a lot of rows for setting in table. This structure is basicly key-value pair usage. But! My advice use structure below.

public class Setting : Entity
{
    public int Id { get; set; }
    public string SiteName { get; set; }
    public string ProductsPerPage { get; set; }
    ...
}

Because, it will be easy to caching. You can fetch all Setting table and just cache it. Easy caching and no more queries.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.