>I'm considering taking the approach of making the appropriate email
>routines that
>follow validation routines, "children" (I think that's the term) of the
>validation routines
>so there's only one call from the calling page and then the data flows
>through the
>process of validation and emailing, then returns to the calling page
>only once.
I think best design would have both your validation() and email()
methods entirely ignorant of each other. They do what they say they do
- one validates data, the other sends an email. The calling template
acts as the 'controller' and coordinates the calls. This gives you the
most flexibility and reusability.
Let's say that the validation method returns a structure of error
messages related to form fields (the struct keys being the form
element names). If this was called from within the sendEmail() method,
you might be limited with what you could do in terms of handling those
errors, or, if not limited you'd have to scratch your head a bit to
figure where the handling should go and how it should all be handled.
Seperate the logic out and you have:
<cfset errors = someComponent.validationMethod( argumentCollection = form ) />
<cfif StructIsEmpty( errors) >
<cfset result = someComponent.sendEmail( argumentCollection = form ) />
<cfelse>
<!--- do some error handling --->
</cfif>
Even if you will have a much simpler error system, ie. true or false
to validation, seperating the logic to this extent gives you the
flexibility to change the error handling without having to change the
rest of the code.
While making less 'calls' from your calling page may seem like a noble
cause, you should be weary of sacrificing separation which is what you
would being doing here.
HTH
Dominic
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314726
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4