[Nitro] Simpler configuration method?

George Moschovitis george.moschovitis at gmail.com
Thu Jan 25 05:01:32 EST 2007

Dear devs,

I am thinking about replacing the current configuration/settings
system used in Nitro and Og with a much simpler implementation
based on global variables. Let me demonstrate with an example:

instead of

class Server
  setting :root_dir, :default => 'public', :doc => 'The default dir'

dir = Server.root_dir

use the following:

$server_root_dir = 'public' # The default dir

dir = $server_root_dir

The main drawback of the current version is that you have to
define the classes to be configured before executing any configuration
code and/or require the glue/configuration.rb file. This prohibits
the reusability and flexibility of the configuration files. Moreover,
as the configuration system uses annotations there is a slight performance
penalty that may be serious if a configuration variable is used
in a tight loop.

I understand that global variables are considered evil, but I think
they are very suitable for configuration. I especially like the
fact that global variables default to nil (==false) if they are not
previously defined.

I would like to hear some opinions on this.

thanks in advance,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/nitro-general/attachments/20070125/d5ac9f3c/attachment.html 

More information about the Nitro-general mailing list