Tutorial :Sensible defaults for configuration



Question:

I've recently started to play with Ruby on Rails which favours convention over configuration and relies on sensible defaults to tie various aspects of the application together.

I was thinking that it might be useful if this concept of sensible default configuration was used in general configation for various frameworks then it might save some development headache.

For example, in a .net app I usually want to log an exception in the windows event log using enterprise library exception handling block but if I don't explicity state the behaviour I want in a config file then EL will complain. I think that instead, if it can't find custom configuration then it should revert to a sensible default configuration, like logging my exception in the event log.

Would this be a good or bad concept for frameworks to adopt for their configuration?


Solution:1

I work a lot with a framework that does this exact thing. My trouble with this way of working is that:

  • the framework grew to having an excessive amount of configuration keys that are actually never used/set in a configuration file.
  • behavior of the software becomes implicit sometimes, I want to explicitly set the system to behave a certain way instead of having it fallback on some other code path due to a 'default'.
  • a missed typo in configuration key may result in a very long diagnostic session before figuring out what is going on.

When forgetting to set a configuration value I rather have the software tell me, instead of assuming some form of behavior that I might not at all be after.

I'd prefer a 'template' configuration file in which I change what I want and have the unchanged settings serve as the default.

Figuring which out which convention the software picked when debugging can be a lot of time wasted also.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »