Barney said, "I much prefer a validate() method separate from the
individual getters and setters."

Sean pretty much said the same thing.

I can understand the reasoning behind these comments and I like the fact
that I can wrap up temporary storage of data PLUS validation of that
same data, all in one object.  That makes it very handy to carry around
for multiple purposes.

On the other hand, that is where the limitation is, in my mind.

Let's say I have a user-related object with the following instance
variables:

UserBean.cfc
ID#
SSN
BirthDate
FirstName
LastName
Email

I also have the setters and getters for each instance variable.  These
are all string data types.

In addition, I have a validate() method that checks, obviously, for
valid data.

I want to reuse this same user-related CFC for multiple purposes.  One
use is with a DAO to manage the database operations.  This requires me
to fill "all" variables and validate them.

My other use is to wrap up "some" instance variables, but not all, for a
completely different use, but still user related.  For example, I only
need to pass FirstName, LastName and Email.  Rather than create a new
bean with only these instance variables, I just want to use "part" of my
UserBean CFC.

This is all fine until I run the validate() method.  Then, it will tell
me that ID, SSN and BirthDate are required and/or not of the necessary
data type.

This leads me back to Roland's comment where he uses a struct as a data
object and not an entire CFC.  In Roland's case, his struct can't
validate itself as a CFC can.  Therefore, he must do validation outside
of the data struct.

On the other hand, a struct can't define itself using an init() like a
CFC can. (Unless you write a function that returns a struct with empty
keys.)

To sum it up, how can I use a bean-type CFC to pass several data
elements, validate the data, yet still not "always" require validation?

Thanks
MAD

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:189299
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to