Title: Message
Rather than let the cfc know about the two different ways it can get data, just let it concentrate only on one.  The cfc should only accept firstName and lastName.  In your code that calls the cfc, use a cfif to determine which set of variables will populate the cfc.
 
One mindset that is preached here, and for good reason, is don't make the cfcs aware of their surroundings or assume to know about other variable scopes.  Treat them as introverted black boxes that accept only what you give them.
 
pseudo-code:
 
cfif IsDefined(form)
  objcfc.init(form.firstName, form.lastName)
cfelse IsDefined(struct)
  objcfc.init(customer.firstName, customer.lastName)
/cfif
-----Original Message-----
From: Paul Giesenhagen [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 07, 2003 3:43 PM
To: [EMAIL PROTECTED]
Subject: [CFCDev] Code Reuse

Ok, I am really trying to utilize CFC's and utilize their pronounced ability to handle alot of good code reuse.
 
I have a CFC that handles customer information.  And I have two ways that customer information can be populated and manipulated:
 
1) Through a form (form.firstName, form.lastName)
OR
2) Though a struct being passed to the CFC customer.firstName, customer.lastName
 
It is possible (and good practice) to create 1 simple function that can handle both inputs?  How do you decern between the two scopes?
 
Any suggestions and help would be appreciated.
 
Also, are their any good resources out their for code reuse as it pertains to CFC's or even CFMX in general.
 
Paul Giesenhagen
QuillDesign
 
 

Reply via email to