RE: A question about CFCFactory objects as a singleton ....

2007-01-09 Thread Kevan Stannard
Hi Mike

I would take the approach of passing the user object in as part of your DAO
save (or create and update) method.




Just as you only need a singleton factory, you also only need singleton
DAOs.

Best regards

Kevan Stannard


-Original Message-
From: Mike Kear [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 9 January 2007 5:24 AM
To: CF-Talk
Subject: Re: A question about CFCFactory objects as a singleton 

yes as a matter of routine, my tables usually have fields for:

createdby   (the userid of the person who created this record)
datecreated  (timestamp)
updatedby  (The userid of the last person to alter this record)
dateupdated (timestamp)

So the methods in the DAOs that manipulate the records need to be told who's
doing it.  Since DAOs dont know anything about the application, request or
session scopes, they have to be told what they need to know.   In this case
they dont need to know the curent time (thats from the getdate() function in
the database) but they do need to know the userid of the person initiating
this action.My question was about the best way to pass this info in,
since the application doesnt .instantiate the dao directly, but through a
CFCFactory which knows everything it needs to know to instantiate any CFC
required.

When someone logs in, there is a userbean created in their session scope,
containing their name, userid, access rights and lots more depending on what
else happens in this site.

So the question is about this .if there is only one CFCFactory created
as a singleton in the Application scope, all the users on the site are using
the same instance of the CFC to instantiate whatever CFCS they need.  Each
time, the CFC being created will need to be told who's the user, so it can
update any records it needs to update correctly.   Or perhaps it's better to
pass the userID into each method as it's called rather than into the init
method of the DAO cfc.

The options in my first post were the ones that came to mind as i wrote it,
but there are probably other possibilities

What's brought this to mind now is that i'm working on an app that will have
maybe 150-200 concurrent users, all accessing, creating and updating
records.  In the past i've had plenty of reasonably high traffic sites, but
none with that many users creating and updating records simultaniously.  The
high traffic has all been in the read only category,with the write/update
being one or two people at a time max. Under those low traffic situations it
doesnt really matter to have everyone with their own CFCFactory.   One or
two fo them in RAM isnt a big deal   100-200 of them would definitely have a
performance hit on the site so i can't do that here.

Thats' the background to my question.

Cheers
Mike Kear
Windsor, NSW, Australia
Adobe Certified Advanced ColdFusion Developer
AFP Webworks
http://afpwebworks.com
ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month


On 1/9/07, Josh Nathanson <[EMAIL PROTECTED]> wrote:
>
> It seems like option [B] would use a lot less memory resources.
>
> A little more detail about how your objects are set up would be helpful to
> get a clearer picture.  Do you have multiple tables which each store which
> user/ when created?  It seems like you could have a userID property in
> each
> of your objects that needs to maintain the user info, then do:
>
> myObject.setUserID(session.userbean.getUserID())
>
> before commiting. Then have timestamp field in the db.
>
>
>




~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:266030
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: A question about CFCFactory objects as a singleton ....

2007-01-08 Thread Teddy Payne
Are you putting the entire factory into session or the results of the
factory?

It seems like to me that you put your factory into a less transient scope
like your application scope and then your user's session invokes an
instances of the factory as related to the user.

As for credentials, how much do you really need about the user?  You could
instantiate a bean of the user into the session scope, but that is just the
bean for the user and not a gateway or DAO.  The rest of your application
can use the bean of the user in whichever gateway or DAO that you need.

Teddy


On 1/8/07, Mike Kear <[EMAIL PROTECTED]> wrote:
>
> yes as a matter of routine, my tables usually have fields for:
>
> createdby   (the userid of the person who created this record)
> datecreated  (timestamp)
> updatedby  (The userid of the last person to alter this record)
> dateupdated (timestamp)
>
> So the methods in the DAOs that manipulate the records need to be told
> who's
> doing it.  Since DAOs dont know anything about the application, request or
> session scopes, they have to be told what they need to know.   In this
> case
> they dont need to know the curent time (thats from the getdate() function
> in
> the database) but they do need to know the userid of the person initiating
> this action.My question was about the best way to pass this info in,
> since the application doesnt .instantiate the dao directly, but through a
> CFCFactory which knows everything it needs to know to instantiate any CFC
> required.
>
> When someone logs in, there is a userbean created in their session scope,
> containing their name, userid, access rights and lots more depending on
> what
> else happens in this site.
>
> So the question is about this .if there is only one CFCFactory created
> as a singleton in the Application scope, all the users on the site are
> using
> the same instance of the CFC to instantiate whatever CFCS they need.  Each
> time, the CFC being created will need to be told who's the user, so it can
> update any records it needs to update correctly.   Or perhaps it's better
> to
> pass the userID into each method as it's called rather than into the init
> method of the DAO cfc.
>
> The options in my first post were the ones that came to mind as i wrote
> it,
> but there are probably other possibilities
>
> What's brought this to mind now is that i'm working on an app that will
> have
> maybe 150-200 concurrent users, all accessing, creating and updating
> records.  In the past i've had plenty of reasonably high traffic sites,
> but
> none with that many users creating and updating records
> simultaniously.  The
> high traffic has all been in the read only category,with the write/update
> being one or two people at a time max. Under those low traffic situations
> it
> doesnt really matter to have everyone with their own CFCFactory.   One or
> two fo them in RAM isnt a big deal   100-200 of them would definitely have
> a
> performance hit on the site so i can't do that here.
>
> Thats' the background to my question.
>
> Cheers
> Mike Kear
> Windsor, NSW, Australia
> Adobe Certified Advanced ColdFusion Developer
> AFP Webworks
> http://afpwebworks.com
> ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month
>
>
> On 1/9/07, Josh Nathanson <[EMAIL PROTECTED]> wrote:
> >
> > It seems like option [B] would use a lot less memory resources.
> >
> > A little more detail about how your objects are set up would be helpful
> to
> > get a clearer picture.  Do you have multiple tables which each store
> which
> > user/ when created?  It seems like you could have a userID property in
> > each
> > of your objects that needs to maintain the user info, then do:
> >
> > myObject.setUserID(session.userbean.getUserID())
> >
> > before commiting. Then have timestamp field in the db.
> >
> >
> >
>
>
> 

~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:265981
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: A question about CFCFactory objects as a singleton ....

2007-01-08 Thread Mike Kear
yes as a matter of routine, my tables usually have fields for:

createdby   (the userid of the person who created this record)
datecreated  (timestamp)
updatedby  (The userid of the last person to alter this record)
dateupdated (timestamp)

So the methods in the DAOs that manipulate the records need to be told who's
doing it.  Since DAOs dont know anything about the application, request or
session scopes, they have to be told what they need to know.   In this case
they dont need to know the curent time (thats from the getdate() function in
the database) but they do need to know the userid of the person initiating
this action.My question was about the best way to pass this info in,
since the application doesnt .instantiate the dao directly, but through a
CFCFactory which knows everything it needs to know to instantiate any CFC
required.

When someone logs in, there is a userbean created in their session scope,
containing their name, userid, access rights and lots more depending on what
else happens in this site.

So the question is about this .if there is only one CFCFactory created
as a singleton in the Application scope, all the users on the site are using
the same instance of the CFC to instantiate whatever CFCS they need.  Each
time, the CFC being created will need to be told who's the user, so it can
update any records it needs to update correctly.   Or perhaps it's better to
pass the userID into each method as it's called rather than into the init
method of the DAO cfc.

The options in my first post were the ones that came to mind as i wrote it,
but there are probably other possibilities

What's brought this to mind now is that i'm working on an app that will have
maybe 150-200 concurrent users, all accessing, creating and updating
records.  In the past i've had plenty of reasonably high traffic sites, but
none with that many users creating and updating records simultaniously.  The
high traffic has all been in the read only category,with the write/update
being one or two people at a time max. Under those low traffic situations it
doesnt really matter to have everyone with their own CFCFactory.   One or
two fo them in RAM isnt a big deal   100-200 of them would definitely have a
performance hit on the site so i can't do that here.

Thats' the background to my question.

Cheers
Mike Kear
Windsor, NSW, Australia
Adobe Certified Advanced ColdFusion Developer
AFP Webworks
http://afpwebworks.com
ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month


On 1/9/07, Josh Nathanson <[EMAIL PROTECTED]> wrote:
>
> It seems like option [B] would use a lot less memory resources.
>
> A little more detail about how your objects are set up would be helpful to
> get a clearer picture.  Do you have multiple tables which each store which
> user/ when created?  It seems like you could have a userID property in
> each
> of your objects that needs to maintain the user info, then do:
>
> myObject.setUserID(session.userbean.getUserID())
>
> before commiting. Then have timestamp field in the db.
>
>
>


~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:265979
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: A question about CFCFactory objects as a singleton ....

2007-01-08 Thread Josh Nathanson
It seems like option [B] would use a lot less memory resources.

A little more detail about how your objects are set up would be helpful to 
get a clearer picture.  Do you have multiple tables which each store which 
user/ when created?  It seems like you could have a userID property in each 
of your objects that needs to maintain the user info, then do:

 myObject.setUserID(session.userbean.getUserID())

before commiting. Then have timestamp field in the db.



- Original Message - 
From: "Mike Kear" <[EMAIL PROTECTED]>
To: "CF-Talk" 
Sent: Monday, January 08, 2007 7:51 AM
Subject: A question about CFCFactory objects as a singleton 


> I'm building an app where usage is going to be FAR higher than anything 
> i've
> used OOP for before, so I am trying to be careful to build it with the
> potential bottlenecks in mind.  In this job i might have several hundred
> concurrent users accessing the application.(in the past i've used it 
> for
> things like a CMS where only one person is going to be using it for an 
> hour
> or so every few days at most, so bottlenecks and performance issues are
> still important but not as high a priority).


~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:265963
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: A question about CFCFactory objects as a singleton ....

2007-01-08 Thread Matt Williams
I choose [B]. Less objects = a good thing.

On 1/8/07, Mike Kear <[EMAIL PROTECTED]> wrote:
> I'm building an app where usage is going to be FAR higher than anything i've
> used OOP for before, so I am trying to be careful to build it with the
> potential bottlenecks in mind.  In this job i might have several hundred
> concurrent users accessing the application.(in the past i've used it for
> things like a CMS where only one person is going to be using it for an hour
> or so every few days at most, so bottlenecks and performance issues are
> still important but not as high a priority).
>
> I have a CFCFactory, that generates all the DAOs and Beans as i need but
> since every record has a trace of who created it and when, and who was the
> last to access it and when, the CFCFactory needs to pass to the CFC the
> credentials of the user.   My question is about the best way to pass the
> credentials in 
>
> A couple of scenarios:
>
> [A] Should I give each logged in user their own instance  of the CFCFactory
> in the session scope,   telling the CFCFactory their login credentials when
> it's instantiated.   Then the CFCFactory passes the credentials on to each
> CFC as they're instantiated
>
> OR
>
> [B]  Have only one instance of the CFCFactory in the application scope,
> passing in the credentials to the createbean(session.userbean) or createDAO(
> session.userbean) method as it's called
>
> OR
>
> [C] I've missed the point entirely and there's a whole n'other way to look
> at it and get the user's credentials down to the final insert/update query.
>
>
>
> --
> Cheers
> Mike Kear
> Windsor, NSW, Australia
> Adobe Certified Advanced ColdFusion Developer
> AFP Webworks
> http://afpwebworks.com
> ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month
>
>
> 

~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:265960
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4