I'm trying to get my head around some good practices for using CFCs. I
suppose it's old hat to those with OO backgrounds, but let's discuss a
hypothetical application.

Let's say you're building an e-commerce application. Among the various data
you have users and shipping addresses. Users can create, list, view, edit
and delete their shipping addresses as well as associate them with orders.
Administrators can also list, edit and delete shipping addresses, but their
criteria would likely be different. For instance, viewing all shipping
addresses in New Jersey, for instance, or those that have never had an order
sent to them.

The front-end stuff I got, no sweat. I want to encapsulate all of the
database functions in CFCs.

My questions then:

How would you set up your CFC? In other words, what components would you
create? What methods would you use? For instance, would the component used
to bring back a query with a user's 0-n shipping addresses be the same
component used to modify a particular shipping address? The SQL to pull a
list of shipping addresses and the SQL to pull one based on its primary key
is different only in the WHERE clause used. How do you maximize
code--including SQL--reuse without going crazy?

Further, and in general, how do you organize your CFCs?


p.s. Yes, this really is a hypothetical application I'm talking about. We're
not even close to moving to CFMX in my day job, and none of my hobby stuff
has anything to do with shipping addresses. So you're not building an
application for me. <cf_grin>

______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to