On 10/23/07, Jonathon Stierman <[EMAIL PROTECTED]> wrote:
>
> >> First, you can use constructor injection instead of setter injection
>
> In some cases, yes.  In other cases, I have circular dependencies, which
> cannot use constructor injection.  I typically always use setter injection
> for this reason -- I find it's more flexible.


Sure. I just wanted to make sure you were aware that you don't HAVE to use
setter injection. It's only mandatory when you have circular dependencies.

>> Second, you seem to be calling a database relationship a "dependency",
> which I'd say isn't accurate.
>
> I completely agree that dependencies aren't always having to do with
> database calls -- in my applications they typically are, however.  I've
> got
> a few "service" CFC's that I pass around to my DAO's, but mostly my
> "dependencies" have to do with field validation.
>
> Say I've got a Book entity that has one or many Authors.  Assuming "Books"
> and "Authors" are each tables in the database, when I create a Book
> record,
> I call my BookDAO.cfc -- in this CFC is a validate method that checks to
> make sure all the Authors the user assigned to this Book are indeed valid
> records in the Authors table.  In this case, I pass BookDAO.cfc a
> reference
> to AuthorsDAO.cfc and that gives me the ability to query for Authors from
> the BooksDAO save method.


While I understand the need to do validation on your data, I don't follow
this example. A simple foreign key constraint would do this with no extra
work on your part. But in general Transfer will let you define a custom CFC
that wraps the Transfer-generated bean, and you can insert any code you want
into that. I wouldn't want to have my BookDAO need to talk to AuthorsDAO
since (in my opinion) data validation isn't the job of the DAO.

Again, I'm a new developer getting my feet wet :) So if there's an easier
> way that I'm missing, let me know!  I continue to hear "Transfer/Reactor
> will do this," so maybe I gave up on it too quickly!


Sure, learning is good. ;-)  I think the easier way to do what you've stated
so far is to just have a foreign key constraint on your author ID column,
and catch the error in your BookService for proper handling and display back
to the user. If you have other questions about validation, feel free to ask
here or on the Transfer list.

Jonathon
>
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade to ColdFusion 8 and integrate with Adobe Flex
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:291920
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