Hi Janet,

On 12/20/06, Janet MacKay <[EMAIL PROTECTED]> wrote:
>
> Since you mentioned DAO's..


Just to clarify ... when I mentioned DAOs, I was using the term generically;
that is, to apply to both gateways and data access objects in the smaller
sense. In other words, a gateway is a type of data access object; but the
same term/acronym - DAO - gets applied to the object that deals with a
single row of a table.


> Most of the gateway examples I've looked at _basically_ perform read
> operations only. Where do multiple deletes or smaller update operations fit
> into the picture? For example a method deletes all records matching a list
> of ids or updates only one or two fields (like shippingDate) of 1-n records.


First, let me say again that if there's one thing I'm learning about
object-oriented architecture, it is that you are constantly making choices
on whether to follow strictest "best practices." There's a continual
trade-off between keeping everything clean and separate and overcomplicating
your application. While I'm at it, I'll suggest that you join the CFC-Dev
list (also at House of Fusion), since it's focused on CFCs. And perhaps if
you go a little further, you might want to explore the mailing lists for one
or more of the MVC-based code frameworks like Model-Glue or Mach-II. Even if
you're not interested in using a framework, these lists often contain just
the sort of architectural discussions you're wrestling with.

Now -- back to your question: certainly there's nothing wrong with putting
these methods in a gateway. In particular, the multiple delete makes sense
there, because you're going to basically say "DELETE FROM table WHERE id IN
(#myList#)" or "DELETE FROM table WHERE someField = #someValue#." It would
be silly to do the deletes individually.

As far as the updates go -- it depends. (That's a phrase you'll  hear every
two seconds in object-based architectural discussions.) If you're just
gathering up some record IDs and applying an update to a single field, you
may want to put the method in the gateway -- because the SQL would be just
about as simple as the above "DELETE" statement.

On the other hand -- let's say your user is working with a page where s/he
might be changing values for several records, but might be updating
different fields for different records. In that case, since you don't know
what's been changed for any individual record, you can't do a bulk update.
So naturally, you need to grab all the values for a given record, whether
they've changed or not, and update that individual record -- through a DAO.

One guideline that's been helpful to me is this: if you operate on multiple
records with a simple SQL statement, just put it in the gateway. After all,
one big point of all this object-oriented stuff is to keep things simple and
encapsulated, easy to find and easy to maintain. Don't let theory keep you
from doing what makes common sense to you.


-- 
Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:264617
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to