>
>> On Friday, August 30, 2002, at 10:35 , Jeffry Houser wrote:
>>> I think this is too good of a topic to pass up, and I haven't seen any
>>> other responses, so.. I'll give it a shot.
>>
>> Well, I was drafting a reply but didn't have time to finish it... and
>> you'
>> ve actually said most of what I was going to say!
>>
>>> There is some parallel to CFCs with Objects, however I think that a
>>> better comparison is Abstract Data Types (ADTs).
>>
>> Interesting comparison. I'm not quite sure why you'd make that
>> comparison given that CFCs map to Java classes directly - could you
>> elaborate? (It's been years since I dealt with ADTs so my recollection
>> of them may be hazy by now)
>>
>>>> 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?
>>
>> Jeffry didn't directly address this so here's what I'd add to his
>> comments:
>>
>> Inside the ShippingAddress component, I'd have a private method that
>> actually contained the SQL and took an optional whereClause argument.
>>
>>> GetShippingAddressFromOrder (returns a structure, given the orderID)
>>
>> Calls getShippingAddressByQuery(whereClause="orderid = #orderid#") then
>> converts the single query record into a struct and returns it.
>>
>>> GetShippingAddressFromUserID (returns a query object of addresses,
>>> based
>>> on the userID)
>>
>> Calls getShippingAddressByQuery(whereClause="userid = #userid#") and
>> returns the result.
>>
>>> GetAllShippingAddresses (Returns a query object addresses, only for
>>> admin
>>> users only)
>>
>> This would be protected by roles="admin" (assuming you use cflogin /
>> cfloginuser roles="admin" to identify admin users at login).
>>
>> Calls getShippingAddressByQuery() and returns the result.
>>
>> <cffunction name="getShippingAddressByQuery" access="private"
>> returntype="query" ...>
>> <cfargument name="whereClause" type="string" required="false"/>
>> <cfset var actualWhereClause = ""/>
>> <cfset var result = 0/> <!--- local: result of cfquery below --->
>> <cfif isDefined("arguments.whereClause")>
>> <cfset actualWhereClause = "WHERE " & whereClause/>
>> </cfif>
>> <cfquery name="result" ...>
>> select * from ... #whereClause#
>> </cfquery>
>> <cfreturn result/>
>> </cffunction>
>>
>> (mod some tweaks maybe to ensure appropriate quote behavior in the query
>> etc).
>>
>>> I prefer to handle all display out of components, but someone might
>>> want
>>> to consider creating a component to handle display code also.
>>
>> I'd lean toward custom tags for formatting - CFCs should be independent
>> of their environment and should not generate HTML. That approach makes
>> it easier to reuse CFCs later for web services or Flash invocation.
>>
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood
>>
>>
>>
>>
>>
______________________________________________________________________
Get the mailserver that powers this list at http://www.coolfusion.com
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