in reply to Config::General inheritance [SOLVED]

Effective Java has some good advice: Favor composition over inheritance

Having to write your own new method is a sign that Config::General wasn't designed for you to subclass it (although you managed to do it with a constructor hack)

  • Comment on Re: Config::General inheritance [SOLVED]

Replies are listed 'Best First'.
Re^2: Config::General inheritance [SOLVED]
by fbicknel (Beadle) on Mar 04, 2011 at 16:44 UTC
    Thanks for the suggestion: I read the item. But it's unclear whether composition is warranted in this case. I could probably get by without overlaying ->new, and in fact my modifications are small. The main reason I decided to use inheritance was to ease the implementation of Config::General over my own Local::Config. It turns out that most of my existing Config was a subset of Config::General's behavior, so I figured that by adding in a subclass those bits that weren't implemented, I could satisfy all the legacy code's Local::Config features and then start writing new code that capitalized on Config::General's features as well.

    I have to admit your suggestion gives me pause, however. I'll give it another look before finalizing anything and will keep these points in mind as I work further on it.

    Thanks!