Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
-or- I've got a sytem that uses a Session module to define and control all the business rules of any given application. It uses a object factory method:
########################################### # object factory method # $class is the class of the method to be created sub new_object { my $self = shift; my $class = shift; my $id = shift; my $dbh = $self->{'dbh'}; my $object = { 'id' => $id, 'dbh' => $dbh, }; bless $object, $class; $object->init; return $object; }

$class is the object class, $id is an optional object id (for instatiating a particular object from a database for example). The method then calls $class->init which is an initialization method which handles all the details of the given class. Essentially it's just a generic constructor. Technically your classes don't need one if they are going to be called by the base module.

You have to use all the modules you plan to invoke this way in the base "Session" module, but you already know all the modules you're going to use, right?

-Matthew


In reply to Re: Runtime loading of arbitrary objects by matthew
in thread Runtime loading of arbitrary objects by Anonymous Monk

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?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (1)
As of 2024-04-19 00:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found