Hey – honestly, if you’re THAT hung up on terminology, then you’re not concentrating on the problem.  I think that we, as a community, need to stop being so hung up on patterns and terminologies and start concentrating on solving actual problems.  I mean, I definitely agree that it’s nice to have a lingua franca, but if I see one more freaking debate about what constitutes a Gateway, vs. what constitutes a Manager, vs. what constitutes a Factory on this list, I swear to Bog that I’m going to start shooting people.  There are a bunch of extremely bright people on this list – it never ceases to blow my mind how many times we’ve argued about semantics instead of arguing about solutions.

 

Bonus points if you get the Bog reference.

 

Roland

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nando
Sent: Monday, November 14, 2005 4:01 AM
To: [email protected]
Subject: RE: [CFCDev] Factory Pattern - yes this IS about Factory Pattern!

 

Mike,

 

I enjoyed reading your posts this morning, especially the one about the throngs of bank customers meeting in the road.

 

It's hard for me too. Someone will say, for instance, that a Service is X. Then someone else will say that a Service is Y and that X is a Manager. Then someone else will say that if you are using Managers in your model, you don't understand OO design very well. Then Joe gets around that in Model-Glue by calling them Controllers, and i think to myself, "Gee, that was clever!" ;)

 

I'm going to call it a Service. Think of the guy in the truck selling hot dogs to the throngs of bank customers crossing the road. That's a Service, right?

 

Here's what i've done, in case it's of any help.

 

In Application.cfc/m instantiate Factory as a singleton. Then have Factory make you instance of DaoService. When it does, pass the instance of the factory into it, using "this".

 

in Factory:

<cffunction name="getDaoService" access="public" returntype="DaoService" output="no">
  <cfset var DaoService = createObject('component','DaoService').init(this) />
  <cfreturn DaoService />
 </cffunction>

 

In Application.cfc/m, or wherever actually needed.

(adjust as necessary)

<cfif NOT StructKeyExists(application, "DaoService") OR StructKeyExists(url, "reinit")>
 <cfset application.DaoService = application.Factory.getDaoService() />
</cfif>

 

 

In DaoService's init method, you'll set the Factory instance you passed into DaoService to variables scope so you've got ready access to it, and then from within DaoService, have factory make all the Dao's you need and set them to variables scope as well.

 

Then you'd access them using public getters. For example:

 

application.DaoService.getSomeSpecificDao().create()

application.DaoService.getSomeSpecificDao().read()

 

I've used this approach to instantiate Gateways into a GatewayService for front end queries. It seems to perform very well, even on views that use many queries to render the page.

 

I'm not suggesting that you specifically use an object called DaoService - btw. It's just to demonstrate.

 

ciao,

Nando

 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Mike Kear
Sent: Monday, November 14, 2005 8:04 AM
To: [email protected]
Subject: Re: [CFCDev] Factory Pattern - yes this IS about Factory Pattern!

Thanks for the link to the Joe article, Sean.  It is excellent.  It definitely meets the needs I was looking for - not too technical.

 

It seems this whole subject is difficult for a lot of people to discuss in terms that us neophytes can easily grasp.  For a long while, every time i THOUGHT I had a handle on it, someone would use some other term I didnt understand, and i'd take time to figure out whether this was a new term for a concept i already knew about, or a new concept I didnt know about yet.

 

Joe, congrats on a well-written, easy to understand couple of articles on the factory and the DAO concepts, and how they relate to CF users.    Nicely done, and thanks a lot!

 

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

 

 

On 11/14/05, Sean Corfield <[EMAIL PROTECTED]> wrote:

On 11/13/05, Mike Kear <[EMAIL PROTECTED]> wrote:
> Right, Sean, and I should have changed it in my last post too.   Sorry
> everyone.

And I responded without changing the subject too - mea culpa! (Can I
claim you're a bad influence on me, Mike? No? I didn't think so!)

> But since this subject line is about factory patterns,  does anyone know a
> not-too-technical place where I can go to learn about it, preferably on
> line?

"not-too-technical" That's a tough question.

I just searched for "factory pattern" on Google and got over 90,000 results :(

I think this post by Joe Rinehart is very good - and reasonably approachable:

http://clearsoftware.net/client/index.cfm?mode=entry&entry=89F69AD3-E081-2BAC-695BECE0066A7203
--
Sean A Corfield -- http://corfield.org/
Got frameworks?

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).

An archive of the CFCDev list is available at www.mail-archive.com/[email protected]

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).

An archive of the CFCDev list is available at www.mail-archive.com/[email protected] ----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).

An archive of the CFCDev list is available at www.mail-archive.com/[email protected]

Reply via email to