I was pretty happy with DBIx::Connect until this Friday when 7 databases on the same host had the exact same connection data.

I had to make 7 new entries in my database configuration file, all the time wondering if AppConfig had some means of defaulting across configurations.

So, I began reading the docs to Resources since I remembered that it supported data inheritance. At the time, the idea did not have much relevance, but after my session of cutting and pasting into my config file, I now knew the value of inheritance of configuration data firsthand!

I was bothered by the following quote from the docs of Resources:

Resources defined in a derived class (like Car) override those specified in a base class. <bothersome> Likewise, resources defined in a container class override those specified in the members.</bothersome> In the above example, a default value for "car.speed" in Car overrides the value of "vehicle.speed" in any Car object, otherwise "car.speed" assumes the value of "vehicle.speed". Same for "car.tire.pressure".

It seems like it should be the other way around: the contained elements should refine the general defaults/expectations of the container class with the information specific to their circumstance. For example: if the front wheels of a car should have a tire pressure 5 more psi than the default, then you would set the default in the container class and then "specialize" it to 5 more psi for the front wheels.

But based on the above docs, the container controls the values of the contained, not vice versa.

Does anyone know why?

Carter's compass: I know I'm on the right track when by deleting something, I'm adding functionality.

  • Comment on should container classes override the value of contained classes (Resources.pm)

Replies are listed 'Best First'.
Re: should container classes override the value of contained classes (Resources.pm)
by adrianh (Chancellor) on Oct 05, 2003 at 20:06 UTC
    For example: if the front wheels of a car should have a tire pressure 5 more psi than the default, then you would set the default in the container class and then "specialize" it to 5 more psi for the front wheels.

    The use of the word "specialize" might be a clue that it might be better to model front-wheels as being a subclass of wheel ;-)

    But, ignoring that, you can argue it the other way. For example. it would make equal sense for a car container to override the default tire.pressure in a different way from a lorry container.

    It's a mildly odd model, but it does make sense (IMO).