So what happens if a role has properties that need to be persisted. For example, say I have a general User object and a User can have multiple roles. In this case, lets say this user has a "Member" role. The Member role includes a membershipID property that should be persisted when creating/editing a User that has the Member role.
Does that make sense? I can see this if the Member object where a sub-class of User, but it's a little foggy using the "has a" relationship. Thanks again, Phillip -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Barney Boisvert Sent: Tuesday, March 09, 2004 3:34 PM To: [EMAIL PROTECTED] Subject: RE: [CFCDev] Objects Object HAS-A relationships are represented as foreign key relationshipts in a DB. With role, you'd just have a roleID field in your person table, unless a person can have multiple roles (fairly likely), in which case you'd have a many-to-many with an intermediary table. None of the role information would need to be persisted as part of persisting the user, since the role is separate. When you persist a person, you save the ID, and when you read a person out of the DB, you'd use that ID to construct the appropriate role object (or more likely in the case of roles, you just provide a reference to a shared instance of the appropriate type). As you can now see, my initial code was a little on the sketchy side, because, for simplicity's sake, I was assuming no persistance. Cheers, barneyb > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Phillip Cave > Sent: Tuesday, March 09, 2004 12:05 PM > To: [EMAIL PROTECTED] > Subject: RE: [CFCDev] Objects > > > Thanks Barney. How would you go about persisting this Role object > along with your person? > > <cfset barney = createObject("component", "person") /> <cfset cmr = > createObject("component", "codemonkeyrole") /> <cfset > barney.setRole(cmr) /> > > <cfset personMgr.createPerson(barney) /> // calls > personDAO.insert(person) > > What should personDAO.insert() do with the role object? > > Phillip > > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Barney Boisvert > Sent: Tuesday, March 09, 2004 12:40 PM > To: [EMAIL PROTECTED] > Subject: RE: [CFCDev] Objects > > 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] > > ---------------------------------------------------------- > 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]
