|
CFCs are a place to store data and functionality. Form data, 99% of
the time, should be stored in an object or objects. I validate object
properties at set time - the object property is set if it passes
validation or is not set (if validation fails). If validation fails,
an error message is stored in an array. In other words, my objects all
inherit from a master object that has setProp() and getProp() methods
for getting and setting property values. Within any child object I can
define any validation it requires. When setProp() is called, the
object looks for validation rules for that property and performs a
validation check if found. There's a complex series of private methods
for doing validation and storing, retrieving, and managing an array of
validation failure exception messages for the object. There's also a
validate() method that validates all properties in the object (simply
by looking to see if an exceptions exist. The setProp(), in addition
to performing validation, setting a property/recording an exception,
also removes validation exception messages upon succussful validation.
It is a flexible and powerful way for all of my objects to inherit the
ability to perform validation and to keep all of their data private and
control access to that data. There's going to be an article (and code)
about this and a few other very useful techniques I've implemented in
the April isse of CFDJ. Among those other techniques is a generic
recordset navigation object I wrote some time ago for the application
I'm currently working on. Speaking of CFDJ, the April issue is
focussing on architecture - any of you with the desire to write about
something related to architecture, whether it's a tip or technique or a
full-blown design pattern implementation, feel free to send me an email
off list. ~Simon Simon Horwith CIO, AboutWeb - http://www.aboutweb.com Editor-in-Chief, ColdFusion Developers Journal Member of Team Macromedia Macromedia Certified Master Instructor Blog - http://www.horwith.com GroupOne Dev. wrote: Simon ----------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com). An archive of the CFCDev list is available at www.mail-archive.com/[email protected] |
- Re: [CFCDev] Is Decorator What I Need or Just Extends? Simon Horwith
- Re: [CFCDev] Is Decorator What I Need or Just Extends? Simon Horwith
- Re: [CFCDev] Is Decorator What I Need or Just Extends? Simon Horwith
- Re: [CFCDev] Is Decorator What I Need or Just Extends? Alex Sherwood
- Re: [CFCDev] Is Decorator What I Need or Just Exte... Bill Rawlinson
