[cgiapp] Re: Model design in C::A/Titanium

Mark Stosberg mark at summersault.com
Tue Sep 23 10:00:17 EDT 2008


Richard,

In your design, you have a single entry point to the "model", as you
describe, this point is growing too large for comfort.

I think of the "Model" as a layer, made of up of potentially lots of
model modules.

In my own projects, these almost always end up looking like
CGI::Application plugins. That's because I want a few CGI::App methods
available to them, like 'query()', 'cfg()' and 'dbh()'

Sometimes it's cleaner to use completely separate objects, like Rose::DB
or CGI::Uploader.

If I'm going to use these repeatedly, I wrap them in their own little
wrapper class that simplifies initialization.  

This is much like some CGI::App plugins work, like Session plugin for
example.

And one other suggestion: If you find you are doing this a lot:

    $c->param('model')

Go ahead and make a simple shortcut method for it, so you can just say

 $c->model;

It will be fast to create, cleans up your code, and gives you more
flexibility about implementation in the future. I suggest that as
someone who used param() in just the same way for some time.

    Mark

-- 
 . . . . . . . . . . . . . . . . . . . . . . . . . . . 
   Mark Stosberg            Principal Developer  
   mark at summersault.com     Summersault, LLC     
   765-939-9301 ext 202     database driven websites
 . . . . . http://www.summersault.com/ . . . . . . . .




More information about the cgiapp mailing list