I want to write a mod_perl application that would allow a user to search, sort and browse through a set of records from a database table represented by a subclass of Class::DBI::Pager

I do this often, so I want to encapsulate all that searching, sorting and browsing logic in it's own class with a few customization hooks:

With any luck, I can write a complete web application like this:

package Physemp::Admin::Clients::Browse; use base 'My::Browse'; ## My::Browse is the base browsing class __PACKAGE__->pager_class('Physemp::Model::Account'); sub items_per_page { return 10; } sub search_template_name { return 'path/to/search/template'; } sub result_template_name { return 'path/to/result/template'; } sub wrapper_template_name { return 'path/to/wrapper/template'; } ## whatever other hooks I need 1; __END__

What I'm not really clear on is how to code the pager_class() method I used just above. If I understand properly, the I need the same effect from that as if I had typed

$class = 'Physemp::Model::Account'; require "$class";

in My/Browse.pm.

Perhaps I'm off and a better way to do that exists. I don't consider myself as up on design patterns as I could be, but I think some people call what I'm talking about a factory class.

TIA for any advice y'all give me.


In reply to OO Design Advice Sought by cleverett

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.