[Nitro] Simpler configuration method?

Lars Olsson lasso at lassoweb.se
Thu Jan 25 06:21:16 EST 2007


Hi!

Yes, globals are indeed evil...

How about a Settings/Configuration object (some kind of glorified Hash)?

Something like this:

Nitro.settings[:server_root_dir] = 'some_dir'


Sincerely

/lasso



On Thu, January 25, 2007 10:01, George Moschovitis wrote:
> 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' end
>
> 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, George.
>
>
>
> --
> http://blog.gmosx.com
> http://cull.gr
> http://www.joy.gr
> http://nitroproject.org
> _______________________________________________
> Nitro-general mailing list
> Nitro-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/nitro-general




More information about the Nitro-general mailing list