in reply to converting to a sub-class

That is kind of sick, but I'm sure you have your reasons. For "best practices" I'd suggest using my $backend = __PACKAGE__.'::'.$self->{extension}; instead of hard-coding 'DUM::DUMMY' into the assignment.

I am fascinated; why do you need to do this?

Replies are listed 'Best First'.
Re^2: converting to a sub-class
by Cagao (Monk) on Oct 20, 2007 at 17:29 UTC
    In true OO fashion, imagine the 'base' class as a person, i want to create a subclass of a male person.

    so i have

    Person and Person::Male

    I don't want anyone top create a Person::Male object directly, instead just create a Person object, and I'll subclass it to include new methods, or override common methods.

    make sense? Am I missing something completely mental?

    Thanks for your reply, although i was a bit shocked with "it's sick!" :-/
      It's perfectly sane, don't be shocked :-)

      The technique you're using is related to the Factory Pattern. It's quite an established idea.

      Note that the hint to avoid hard-coding (parts of) the class name is good.

        Ahh yes, the Factory pattern, I'd heard of that, isn't there 2 main ways of doing this sort of thing? Factory being one, what's the other?

        So that use of ->require, etc. looks fine then?

        I'll use __PACKAGE__ in future of course.

        if Person::Male shouldn't be a class, how else would it be done?
    A reply falls below the community's threshold of quality. You may see it by logging in.