Something I have been doing for a while now is making Application.dao and
Application.gateway structs to store all my data abstraction and then passing
those to beans.
Basically, I have a DAOBean object that many of my beans extend which contains
getDAO() and setDAO() functions for passing the reference.
This approach has worked really well thus far, but I want to start making a
factory for creating a new bean (or reading one) as I like that better than
using the bean.load() mechanism that the Active Record pattern typically
uses.
Sorry if this sounds like random jibberish as I haven't been sleeping enough
haha.
Later,
Mike.
On Monday 30 January 2006 8:12 pm, Dave Shuck wrote:
> Matt, I was considering just doing the following so that I am not as tied
> to any particular controller.
>
> For this example, say I am working with a User object and I will have a
> DataGatewayFactory.cfc. On the page that needs the UserGateway, I would do
> something like the following:
>
> DataGateway =
> createObject("component","DataGatewayFactory").init(dsn,username,password);
>
> UserGateway = DataGateway.createDataGateway("User");
>
> then be able to call UserGateway.listSomeUsers();
>
> Inside the factory, the createDataGateway() method would first check to see
> if there is a UserGateway in the application scope. If there is, than
> return an instance of it. If there isn't an instance in the application
> scope, create it and return it.
>
> Does that make sense? Is there anything goofy/dangerous about that?
>
> Thanks...
>
> ~d
>
> On 1/30/06, Matt Woodward <[EMAIL PROTECTED]> wrote:
> > This is more or less what Mach-II does when you put a gateway inside
> > your listener--it will get loaded into the application scope when the
> > Mach-II app first loads. Should be fine (and make good sense
> > actually) to have these objects that you use over and over in the
> > application scope.
> >
> > On 1/30/06, Dave Shuck <[EMAIL PROTECTED]> wrote:
> > > So as not to continually add the expense of re-instantiating gateway
> >
> > CFCs,
> >
> > > is it safe to store an instance of a gateway CFC for each object in the
> > > application scope and just call gateway methods like
> > > application.UserGateway.listUsers()?. I was thinking about
> > > having an application initialization routine in my Mach-II application
> >
> > that
> >
> > > will instantiate each gateway in the application scope
> >
> > onApplicationStart.
> >
> > > Is there a better way of handling this?
> > >
> > > Thanks for any input.
> > >
> > > --
> > > ~Dave Shuck
> > > [EMAIL PROTECTED]
> > > www.daveshuck.com
> > > _______________________________________________
> > > Reply to DFWCFUG:
> > > [email protected]
> > > Subscribe/Unsubscribe:
> > > http://lists1.safesecureweb.com/mailman/listinfo/list
> > > List Archives:
> > > http://www.mail-archive.com/list%40list.dfwcfug.org/
> > > http://www.mail-archive.com/list%40dfwcfug.org/
> > > DFWCFUG Sponsors:
> > > www.HostMySite.com
> > > www.teksystems.com/
> >
> > --
> > Matt Woodward
> > [EMAIL PROTECTED]
> > http://www.mattwoodward.com
> >
> > _______________________________________________
> > Reply to DFWCFUG:
> > [email protected]
> > Subscribe/Unsubscribe:
> > http://lists1.safesecureweb.com/mailman/listinfo/list
> > List Archives:
> > http://www.mail-archive.com/list%40list.dfwcfug.org/
> > http://www.mail-archive.com/list%40dfwcfug.org/
> > DFWCFUG Sponsors:
> > www.HostMySite.com
> > www.teksystems.com/
>
> --
> ~Dave Shuck
> [EMAIL PROTECTED]
> www.daveshuck.com
_______________________________________________
Reply to DFWCFUG:
[email protected]
Subscribe/Unsubscribe:
http://lists1.safesecureweb.com/mailman/listinfo/list
List Archives:
http://www.mail-archive.com/list%40list.dfwcfug.org/
http://www.mail-archive.com/list%40dfwcfug.org/
DFWCFUG Sponsors:
www.HostMySite.com
www.teksystems.com/