in reply to Re: converting to a sub-class
in thread converting to a sub-class

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!" :-/

Replies are listed 'Best First'.
Re^3: converting to a sub-class
by rhesa (Vicar) on Oct 20, 2007 at 17:37 UTC
    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.