>I just can't see the value of tightly coupling an object to a >whole form. What happens if you add another textinput control >because you've had to add another method argument? re-write >the validation object? yuck...
The value is when you have different requirements depending on which form was submitted. At user registration you perhaps don't care whether they fill in an address, but when it comes time for them to upgrade or otherwise modify their membership so you can send them products, you really do care about the address data. In some applications this won't ever be the case, but in most of the ones I've worked on it is. It also comes back to the simple rules of reducing coupling and increasing cohesion. Specifically increasing cohesion. The validation object does one thing and one thing only. It validates the input to a specific form. If you add a field to that form, you only have to add another method to the validation object and call it from the validate() metohd. The code that calls the validation object doesn't need to change. I would hardly call that re-writing. Given that you're going to have to put the validation code for that somewhere it might as well be encapsulated with the rest of the validation code. There are no doubt a lot of scenarios where you want only one CFC to represent the data a single database table, but I've generally found that more often it makes sense to have more than that. >why bother when simply adding the UI element and setting >attributes (eg datatype="date" required="true") will do this for you? I'm not really sure what you're talking about here, but I assume that you mean that this is providing some sort of validation via the cfargument tag. If so, you will almost certainly have to do some pre-processing of the form data to get it to validate as a date. A lot of date entry fields I've worked with use more than one form field and those that don't can't usually be relied on to get the date in a format that will reliably turn into the date you desire. In those cases, your validation object can double-up as a pre-processor for passing the data to a business object, or just act as the business object itself. Spike ---------------------------------------------------------- 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]
