Just to add credibility to my prior emails, I never use DTOs.  ; ) 
DTOs are purposed for reducing expensive remote method calls on
distributed systems.  CF apps don't suffer from this problem, since
they're all local.

In Mach-II (which I don't use either), there are neat tools for
"beanifying" stuff.  That leads you down a certain path regarding how
you pass information around your application: with beans.  Beans (in
this case) are pretty much DTOs with a different name.  Is it a good
thing?  I'd say not.  Is it a bad thing?  Nope.  Just a different way
of meeting the same goal.

My personal preference is to validate all my input with simple
procedural code.  I have a file that includes validation for a form
(every form template has a corresponding validation template).  It
simply checks each field in sequence, building up a collection of
errors.  If there are some, it shows them to the user and regenerates
the form for fixing the errors.  If there aren't any, the controller
passes the form fields to the business layer and let it do it's thing.
 It might find some error and require user interaction again, or it
might just complete as normal.

Here's some psuedo-code:

<cfset myErrors = new ValidationErrors() />
<cfinclude template="val_user.cfm" />
<cfif myErrors.size() EQ 0>
  <cftry>
    <!--- cheap trick to avoid typing out all the arguments --->
    <!--- not sure if i'd endorse the practice --->
    <cfset application.appservice.addUser(argumentcollection=attributes) />
    <cflocation url="success.cfm" />

    <cfcatch type="ValidationException">
      <!--- here's where i'd deal with semantic errors --->
      <cfset myErrors = getValidationErrorsFromBusinessLayer() />
      <cfinclude template="dsp_formaterrors.cfm" />
      <cfinclude template="frm_user.cfm" />
    </cfcatch>
  </cftry>
<cfelse>
  <!--- here's where I'd deal with syntactic errors --->
  <cfinclude template="dsp_formaterrors.cfm" />
  <cfinclude template="frm_user.cfm" />
</cfif>

cheers,
barneyb

On Tue, 2 Nov 2004 11:52:09 -0800, Phil Cruz <[EMAIL PROTECTED]> wrote:
> Barney,
> 
> This is very interesting stuff.  I'm curious, what are you thoughts on
> recent posts about "overuse of DTOs"?
> http://www.corfield.org/blog/index.cfm?do=blog.entry&entry=C82A1C6C-F35E-F792-9688F9460D838E30
> http://martinfowler.com/bliki/LocalDTO.html
> 
> -Phil
> 
-- 
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/blog/

I currently have 0 GMail invites for the taking
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

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

Reply via email to