This is a skeleton that will execute, but won't really do anything.
However, it should illustrate how the different CFCs relate to one another.
It also demonstrates both major kinds of object relationships HAS-A and
IS-A.  The 'person' cfc HAS-A 'role', and the 'managerrole' (and
codemonkeyrole) CFC IS-A 'role'.  The 'role' superclass may or may not be
necessary in your application, but I'd recommend it, if for no other reason
than the typecheck on the person.setRole(role) method's argument.  

-- PERSON.CFC --
<component displayname="person">
  <cfset variables.my.role = "" />


  <cffunction name="getRole">
    <cfreturn variables.my.role />
  </cffunction>


  <cffunction name="setRole">
    <cfargument name="role" type="role" />
    <cfset variables.my.role = role />
  </cffunction>
</component> 

-- ROLE.CFC --
<cfcomponent displayname="role">
</cfcomponent>

-- MANAGERROLE.CFC --
<cfcomponent displayname="managerrole" extends="role">
  <!--- whatever managers do --->
</cfcomponent>

-- CODEMONKEYROLE.CFC --
<cfcomponent displayname="codemonkeyrole" extends="role">
  <!--- whatever code monkeys do --->
</cfcomponent>

-- USE THE CFCS --
<cfset barney = createObject("component", "person") />
<cfset cmr = createObject("component", "codemonkeyrole") />
<cfset barney.setRole(cmr) />

Cheers,
barneyb

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Phillip Cave
> Sent: Tuesday, March 09, 2004 6:02 AM
> To: [EMAIL PROTECTED]
> Subject: RE: [CFCDev] Objects
> 
> 
> I've seen numerous threads on this list that mention this 
> Person "has a"
> Role model. Would anyone care to share how it is implemented?
> 
> Thanks,
> Phillip
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf
> Of Nando
> Sent: Wednesday, March 03, 2004 3:05 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [CFCDev] Objects
> 
> Ummm ... you might want to think twice about that. Some would 
> say that it is
> more correct to model it this way: a Person has a Role, and 
> have Employee,
> Customer, and Vendor extend Role ... In general, it's more 
> flexible that way
> because people often change roles, or can have multiple roles 
> in a system.
> At least that's what i've read here and there. Hopefully 
> someone with more
> experience can comment.
> 
> Then it seems Address is more clear, a Person has an Address 
> and has a Role,
> and Employee, Customer, Vendor, and whatever else comes along 
> later extend
> Role - at least that's how i see it.
> 
> My 2 cents, never try to "take a shortcut" with extension - 
> you'll pay for
> it later - unless of course you like learning everything by 
> experience. And
> if you are the type that HAS to learn everything by 
> experience, like me :),
> then i would suggest trying to "take shortcuts" with 
> extension on as small a
> system as possible.
> 
> :) nando
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] Behalf Of
> Mehdi, Agha
> Sent: Wednesday, March 03, 2004 7:27 PM
> To: '[EMAIL PROTECTED]'
> Subject: [CFCDev] Objects
> 
> 
> Hi,
> I am designing an Object Model for one of my applications and 
> this is my
> first time doing that. I have a Person Class as the base 
> class and Employee,
> Customer, Vendor Classes extend that class. I also have an 
> Address Class
> that works as a subType of each of the subClasses. The Person 
> Class also
> holds communication information like homePhone, cellPhone, 
> workPhone, fax,
> email etc. I was wondering if it would be worth doing to 
> create a separate
> class for communication attributes to work as a subType for 
> Person Class.
> Does it seem to be a good way or just another step?
> Any thoughts will be appreciated
> Agha
> ----
> This email may contain confidential and privileged material 
> for the sole use
> of the intended recipient(s). Any review, use, distribution 
> or disclosure by
> others is strictly prohibited. If you are not the intended 
> recipient (or
> authorized to receive for the recipient), please contact the 
> sender by reply
> email and delete all copies of this message.
> 
> To reply to our email administrator directly, send an email to
> [EMAIL PROTECTED]
> 
> Littler Mendelson, P.C.
> http://www.littler.com
> 
> 
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email to
> [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' 
> in the message of the email.
> 
> CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool,
> Corporation (www.mindtool.com).
> 
> An archive of the CFCDev list is available at
> www.mail-archive.com/[EMAIL PROTECTED]
> 
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' 
> in the message of the email.
> 
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).
> 
> An archive of the CFCDev list is available at 
> www.mail-archive.com/[EMAIL PROTECTED]
> 

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to