Another comment. In the send function you are using the var statements to build an ad hoc data structure. A simpler approach may be to build the data before calling the send function then use CF's pass by reference into the send() as arguments.
For example: DAO = createoject sendto = structnew() sendto.newsletterid = 1 sendto.newletter= DAO.read(sendto.newsletterid) send(sendto)
cffunction name=send
cfargument name="params" type="struct"At 03:00 PM 12/15/2004, you wrote:
I'm rebuilding a newsletter system, and using it as a learning experience in OO. I've already made some fundamental design changes, which worked out to comparably small code changes (I haven't built the database yet, mind you) and things are generally going well. One of the things I'm doing is abstracting various parts of the model when they need to be called in other parts. For example, my newsletterManager class acts as a service locator to the application for the other manager classes, each of which controls access to my DAO and gateway objects. So, my question is, when I need to make multiple method calls to one of these objects, is there any advantage to creating a local reference to the object within my method, or is it purely aesthetic?
Here's an example (since I'm sure I didn't explain that well :)):
<cffunction name="send" returnType="void" output="false" access="remote">
<cfargument name="newsletterID" type="numeric" required="yes" />
<cfset var newsletter = getDAO().read(arguments.newsletterID) />
<cfset var text = getGateway().getTextArray(newsletter) />
<cfset var images = getGateway().getImageArray(newsletter) />
<cfset var template =
getTemplateManager().getDAO().read(newsletter.getTemplate()) />
<cfset var list = getSubscriptionManager().readList(newsletter.getList()) />
<cfset var userList = getSubscriptionManager().getUsersInList(list.getID()) />
...etc.
Now, would it be better to create a reference like this: <cfset var dao = getDAO() /> and then call methods on that? Or, since I'm merely referencing objects which are declared within the newsletter object anyway (the DAO's, gateways and managers are passed in to the newsletterManager on construction,) should I use the original reference, which is 'variables.instance.dao' etc.?
I suppose a better way to ask this is, is the way I'm doing it actually harmful because of unnecessary method calls?
- Ken ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at [EMAIL PROTECTED]
----------------------------------------------------------------------- http://www.switch-box.org/CFSQLTool/Download/
Switch_box MediaFirm, Inc. www.Switch-box.org Loveland, CO USA
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at [EMAIL PROTECTED]
