http://qs321.pair.com?node_id=366846


in reply to Re^4: Draft - Writng pluggable programs with perl.
in thread Draft - Writng plugable programs with perl.

Where on earth are you passing these objects to and from?!? Oh, my Gods! Neither mod_perl nor CGI::Application are anywhere near that complex. Frankly, this is what parent processes and sessions are for.

Now, you may say "Well, isn't a session a context object?" and you'd be right. But, a session contains only enough information to maintain state between requests. The rest should be handled with Singletons.

------
We are the carpenters and bricklayers of the Information Age.

Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

I shouldn't have to say this, but any code, unless otherwise stated, is untested

  • Comment on Re^5: Draft - Writng pluggable programs with perl.

Replies are listed 'Best First'.
Re^6: Draft - Writng pluggable programs with perl.
by sutch (Curate) on Jun 16, 2004 at 22:21 UTC
    I agree that singletons make sense in certain situations.

    In my example above, I was considering that a web application framework was running under mod_perl and serving up multiple sites. So each site could potentially pass a database handle specific to the application requested via the URL, an error log specific to the application requested via the URL, a template object specific.... I'm curious, how would you recommend implementing a framework that requires many objects passed among the objects which make up the framework?

      So, you are talking about having an engine that would be common across sites, but the specifics are, well, specific to each site? Well, obviously you'd pass the right objects around, initialized with the right values from your config file(s). *shrugs* This is the reverse problem from the one the OP is proposing to solve. His problem is how to have an engine, like Mozilla, that would delegate tasks to various expert systems. The problem you're describing is how to customize the engine on the fly so that it behaves differently, depending on the context. I'm not seeing how solutions to the one deal with the other.

      ------
      We are the carpenters and bricklayers of the Information Age.

      Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

      I shouldn't have to say this, but any code, unless otherwise stated, is untested