|Pathologically Eclectic Rubbish Lister|
Dynamic inheritance of subclasses by base classby dpatrick (Scribe)
|on Apr 18, 2002 at 19:32 UTC ( #160317=perlquestion: print w/replies, xml )||Need Help??|
dpatrick has asked for the wisdom of the Perl Monks concerning the following question:
Sistren and Brethren, This is one of those moments where you're thinking of solutions so fast that you can't seem to get out enough brain swallows to understand what it is you're thinking. Here's my issue:
-I've got a base class that lives at ClientName::SupplySite;
-I'm using it in a CGI environment and what it does is setup my $query = new CGI, database connection, and set's a few other variables;
-I'm going to have ClientName::SupplySite::POSearch and I'd like POSearch methods to have access to the internal data structures created from my constructor in ClientName::SupplySite;
-I'd sort of like to be able to do the following whenever I need something from a subclass:
But really not really; I really just want to be able to have access to subclass methods in a convenient way, with them having access to ClientName::SupplySite's $self hash
I'm not interested in the funky stuff in the second line of code there. I've considered making ClientName::SupplySite inherit from it's subclasses, but the down side is that there will probably be multiple sublclasses with methods of the same name. Then I thought about including some magic dust in ClientName::SupplySite the get it to DTRT and new the appropriate subclass when needed so that I'm not loading extra packages for scripts that don't need them. But in the code example above would the search method be fed the $self from the constructor? Yes it would methinks. Maybe I just answered my own question. Everyone, my knowledge of object orientation is spotty.
Pardon my incoherency,
- I think scsh is cool.
Open Sourceror, Perlmonk
Back to Seekers of Perl Wisdom