Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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:

my $ss = new ClientName::SupplySite; my %searchResult = $scc->POSearch->search('supplier', 'foo');

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,


dpatrick
- I think scsh is cool.
Open Sourceror, Perlmonk
http://perlmonk.org/~dpatrick

In reply to Dynamic inheritance of subclasses by base class by dpatrick

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2023-06-04 21:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you go to conferences?






    Results (22 votes). Check out past polls.

    Notices?