I think something similar was addressed in an earlier thread...this is
a quote from the thread (think it was by sean corfield):
"Use the query result - it's already an OO abstraction. Do not convert
your query to an array of objects - aggregate display pages do not
need objects."
On 6/9/05, Chris Peters <[EMAIL PROTECTED]> wrote:
> If you want to use CFCs as an extra layer of abstraction though, create a
> Gateway.cfc for your whole application. Gateway.cfc should have all
> query-related operations in it, and most of the methods should return
> objects, arrays of objects, or simple string/numeric/etc. data. Load an
> instance of Gateway.cfc in your Application.cfm (or Application.cfc) as an
> application- or server-scoped variable so it only loads into memory once and
> is shared by all calling templates. Do it like this:
>
> <cfif not IsDefined('application.team')>
> <cfset application.team = CreateObject('component', 'path.to.Gateway')>
> </cfif>
>
> During development, it's helpful to comment out the <cfif not IsDefined>
> stuff as that causes the instance to "stick" in memory, even if you change
> the source of the CFC. This is good in production because CF doesn't need to
> rebuilt the unchanging instance for every page load.
>
> Let's say your entire application is for team management, so maybe you'd name
> the Gateway.cfc instance "application.team".
>
> Your call to application.team.getTeamMembers() would run a query to get all
> the data you need to build the objects you would put into the array. Loop
> through the query and build your objects as needed. The objects that get put
> into the array should have no queries built into them. Return the array of
> objects.
>
> Douglas's point of the queries being an abstraction in itself is also valid,
> but I mainly construct my code that way only if it's a smaller application.
> Keep in mind that the only way it is an abstraction is if you alias the field
> names, as in
>
> SELECT
> BL_ID AS blahID,
> BL_NAME AS blahName
> FROM ...
>
> Hope that helps.
>
>
> - Chris Peters
>
> >just create a CFC, teamGateway.cfc for example, that returns a query of your
> >team members. The query result is already an abstraction, use it.
> >
> >DK
> >
> >On 6/9/05, Cedric Villat <[EMAIL PROTECTED]> wrote:
> >>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking
application. Start tracking and documenting hours spent on a project or with a
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:209147
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54