in reply to Re^2: Application-wide configuration
in thread Application-wide configuration

The only think I can see subclassing be useful for is if you have to deal with more than one configuration file per application. I read the problem as needing to have a single config file shared by many modules.

Reusability is not affected. Any other application that needs to have a single config file shared by many modules can reuse this module.

Replies are listed 'Best First'.
Re^4: Application-wide configuration
by akho (Hermit) on Jul 27, 2007 at 19:24 UTC
    People have different approaches. But I meant a situation like this:

    I have two applications, each of them uses a database. Database name and other credentials are stated in separate configuration files. So, each of their configuration files contains a parameter named 'database'.

    If I later want to reuse ORM classes from both applications in a new application, I will not be able to do this if they use the same Config::Once class. (I will necessarily have several configuration files too, of course). That's what I meant by 'reusability'.

    This is probably ugly, but such thing happen.

    There may also be problems with separate web applications running under mod_perl (won't they share the same perl process and the same Config::Once, too?), though I may be mistaken.

    So I think simply using Config::Once everywhere is slightly easier, but may turn out to be a problem in some corner cases. Subclassing is a better practice.

    This is not very different from, say, common practice using Rose::DB.