I (and I'm pretty inexperienced with objects, methods and the like) think
one method is OK: you could consider it a method that retrieves products
based on certain criteria. If no criteria are supplied then all the products
are returned. 

Alternatively you could have this method behind the scenes and build two
methods (say getAllProducts() and getProductById() ) as wrappers. Then
you've only got one query. 

Alternatively alternatively you could have a recordSet object with
addCriterion() and retrieve() methods. You'd instantiate the recordSet, add
criteria or not, then retrieve the result. Would be hopeless at joins.

> -----Original Message-----
> From: jon hall [mailto:[EMAIL PROTECTED]
> Sent: Thursday, 29 May 2003 11:43 a.m.
> To: CF-Talk
> Subject: two functions or one?
> 
>   I've run into this issue more than once, and am always not sure
>   about the best way to go about this...
> 
>   I have an app that will require a way to get a list of, for example
>   all products, and the same app needs to be able to get just one of
>   the products using the product id.
> 
>   The query to the database is very similar in both cases, the only
>   difference being the Where clause in the latter query. The two
>   options I see are to build two methods, one called getProducts() and
>   another called getProduct(), or build one method called getProduct()
>   and give it an optional argument for the product id.
> 
>   Building one method is quicker, and makes for a less complicated
>   object model, but for some reason I feel like it starts a slippery
>   slope to mixing the data layer and the logic layer. Maybe the
>   feeling is unfounded though, but maybe not. I'm not sure...
> 
>   I'd be really interested in hearing opinions on which method you guys
>   prefer.
> 
> --
>  jon
>   mailto:[EMAIL PROTECTED]
> 
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Host with the leader in ColdFusion hosting. 
Voted #1 ColdFusion host by CF Developers. 
Offering shared and dedicated hosting options. 
www.cfxhosting.com/default.cfm?redirect=10481

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to