Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>It depends</strong> on your requirements, each one of these options has it own advantages and disadvantages. It tried to list a few:</p> <p><strong>1. Store in Database table</strong> <br> <em>Advantages:</em></p> <ul> <li>Relatively easy to read settings.</li> <li>Possible to write/update settings.</li> <li>Access is to the database is fast.</li> <li>Updates to database values are immediately available.</li> <li>DB is can be shared across multiple instances in clustered environment.</li> </ul> <p><em>Disadvantages:</em></p> <ul> <li>More infrastructure required than the rest of the options (i.e. tables, db access etc).</li> <li>If done incorrectly DB IO can become an issue. (Can be solved with caching strategies)</li> </ul> <p><br><br> <strong>2. Store in web.config file</strong><br> <em>Advantages:</em></p> <ul> <li>Simple to add and access settings.</li> </ul> <p><em>Disadvantages:</em></p> <ul> <li>Changes to the <code>web.config</code> may result in the application pool to restart. </li> <li>Settings are generally not encrypted.</li> <li>In a clustered environment the file has to be kept in sync with other instances.</li> <li>Generally have to deal with strings data types and possible invalid user input when settings are set.</li> </ul> <p><br><br> <strong>3. Store in class as const field</strong> <br> <em>Advantages:</em></p> <ul> <li>Very simple to work with.</li> <li>Can work with static types.</li> <li>Good first step towards refactoring settings into one of the other options.</li> </ul> <p><em>Disadvantages:</em></p> <ul> <li>Requires rebuild for settings to change.</li> </ul> <p><br></p> <p><strong>4. In XML file</strong><br> <em>Advantages:</em></p> <ul> <li>Convenient for storing complex settings such a hierarchies.</li> <li>Custom XML config settings can be embedded inside the web.config. (Popular option see <code>log4net</code> as one such example)</li> <li>Updates to the config files can be made without restarting the application pool.</li> <li>An XSD can enforce the validity of the settings in the file (both structure and data types)</li> </ul> <p><em>Disadvantages:</em></p> <ul> <li>It is XML. Not <em>really</em> human readable, formats like YAML improves on that.</li> <li>Implementation required to parse XML for reading and writing settings.</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload