Title: Message
Global Search and Replace
 
:)
-----Original Message-----
From: Paul Giesenhagen [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 07, 2003 4:02 PM
To: [EMAIL PROTECTED]
Subject: Re: [CFCDev] Code Reuse

Yes, I see your point, but it seems that you have a chunk of code (the cfc) that is re-usable (which is good), but everwhere you call the cfc you have to update if you change firstName to first_name thus it leaves you in the same situation before you did code reuse.
 
This is probably what is tripping me up the most ... I would like to pass a struct, set of forms or query to the cfc and have it process ..
 
I also understand that if I change firstName to first_name I will have alot of changes anyway.
 
Just trying to grasp it all before I head deep into the outfield.
 
Paul Giesenhagen
QuillDesign
 
----- Original Message -----
Sent: Tuesday, October 07, 2003 3:53 PM
Subject: RE: [CFCDev] Code Reuse

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