Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Runtime loading of arbitrary objects

by matthew (Acolyte)
on Aug 21, 2000 at 17:48 UTC ( #28806=note: print w/replies, xml ) Need Help??


in reply to Runtime loading of arbitrary objects

-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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://28806]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2021-04-13 14:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?