On 7/7/07 3:54 AM, "Jaime Metcher" <[EMAIL PROTECTED]> wrote:

> I do find some of the CF idioms baffling.
> Applying the principles of encapsulation, coherency and DRY I come up with
> very different answers.

I find Service classes work well to separate the concerns of class methods
from instance methods. I create a service singleton for each business object
and it handles what could be done using class methods in other languages
(although note this approach is common in Java which supports class methods
so it isn't a work around forced by the lack of class methods in CF - at
least for me). I like it because I can put all of my class methods (new(),
getByFilter(), getByProperty(), deleteByProperty(), deleteByFilter(), etc.)
into %BusinessObjectName%Service and all of my instance methods (get(),
set(), validate(), save(), etc.) in my business objects. As a side note, I
include a save() method in my service classes to provide a complete remote
API. Self persisting beans are a nice idiom, but don't work "over the wire"
so for web services, flex, ajax, etc. you need a Service.save() method,
although in my case I just create a new business object and delegate the
details of persisting to it.

The one thing in CF that makes no sense to me is gateways. Either people
have a 1:1 mapping between columns and properties, do all the heavy lifting
in views or stored procs, have a heavy service layer that operates on dumb
value objects as opposed to beans with the potential for rich getters and/or
setters and/or they repeat themselves between the code that transforms their
gateway recordsets in the service layer and the rich getters in their
business objects. That was why I got into the whole IBO thing and I can't
imagine coding any other way in CF. In Ruby or (shudder) Java, I'd just
create and return a collection of rich business objects. In CF that may be
possible in CF8, but the IBO is working out so well for me I don't have a
reason to take the performance hit to solve a problem I don't have.

Best Wishes,
Peter






You are subscribed to cfcdev. To unsubscribe, please follow the instructions at 
http://www.cfczone.org/listserv.cfm

CFCDev is supported by:
Katapult Media, Inc.
We are cool code geeks looking for fun projects to rock!
www.katapultmedia.com

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]

Reply via email to