cleverett has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: OO Design Advice Sought
by eric256 (Parson) on Nov 18, 2003 at 22:46 UTC | |
by cleverett (Friar) on Nov 18, 2003 at 22:52 UTC | |
by eric256 (Parson) on Nov 18, 2003 at 23:07 UTC | |
by cleverett (Friar) on Nov 18, 2003 at 23:26 UTC |