Yes, I've seen that too but I am too lazy to write individual methods to
return values from methods that are already in the other object; I do see
the power of your suggestion though and I'll keep it in mind for later.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, 16 March 2005 8:27 
To: CF-Talk
Subject: RE: Object composition and calling objects

James

You don't necessarily need to return an object, an alternative is to use
composition as a form of encapsulation:

Example, you have a cfc responsible for validation

<cfcomponent output="no" hint="The central component">

  <cfset variables.oObject1 = "" >
  <cfset variables.oObject2 = "" >

  <cffunction name="init" output="false" returntype="void" access="public"
hint="The method to instantiate a new object">
    <cfset variables.oObject1 = CreateObject("component","Component1")>
    <cfset variables.oObject2 = CreateObject("component","Component2")>
  </cffunction>

  <cffunction name="doSomething" >
        <cfargument name= "personname" >
        <cfargument name="personAge" >
        <cfset rs = variables.oObject1.doSomethingElse(personName,PersonAge)
>
    <cfreturn rs >
  </cffunction>
 
In the above example you can swap out the functionality by changing the
object held in variables.oObject1 but keep the interface for your cfc the
same (i.e. you do not need to change the arguments passed to doSomething
Even though the object you pass the arguments to internally has changed.

  <cffunction name="doSomething" >
        <cfargument name= "personname" >
        <cfargument name="personAge" >
        <cfset rs = variables.NewObject.doSomethingNew(personName,PersonAge)
>
    <cfreturn rs >
  </cffunction>


HTH

Kola  

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:198934
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=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to