Hi Judah,
That sounds about right. So you'd have something like:
getContactByID(id):
// whatever arrangement you have for grabbing the right record out
of the database
query = select from Contact left join PhoneContact left join
EmailContact where ContactID = :id
if (query.contactType is "phone")
return CreateObject("PhoneContact").init(query.Field1,...)
else if (query.contactType is "email")
return CreateObject("EmailContact").init(query.Field1,...)
The PhoneContact and EmailContact objects would be inheriting some of those
fields from Contact. The main point is that you ask for a Contact, but what
you actually get back is on of the subtypes.
Jaime
> -----Original Message-----
> From: [email protected]
> [mailto:[EMAIL PROTECTED] On Behalf Of Judah McAuley
> Sent: Thursday, 13 November 2008 8:45 AM
> To: [email protected]
> Subject: [CFCDEV] Is inheritance the right choice here?
>
>
> I'm trying to sort out the best way to model a scenario. The
> basic setup is this:
>
> I've got a queue of contacts that will be going out. Each
> Contact has some common information about it like an id, the
> customer it is associated with, and a method.
>
> The method can be either a phone contact or an email contact.
> Depending on which type it is, I need to have further
> (different) information. So a phone contact will need to have
> the phone number its going to along with some miscellaneous
> info. If it is an email contact, it needs an email address it
> is going to, the subject, body, etc.
>
> So how best to implement this with cfc's? Should I have one
> cfc for the Contact class with getters and setters for the
> information that is common to all contacts and then have to
> other cfc's that extend the base Contact, one for email
> contacts and one for phone contacts? I think that is the
> correct way to do it, but I'm second guessing myself.
>
> And if that is the correct way, what is the preferred way to
> get a contact as a whole? My assumption is that in my getter
> for the Contact object, I'd pass in an id for the Contact,
> then within the getter I'd check the contact method and
> either run the emailContact getter or the phoneContact getter
> to fetch the object representing the method-specific info.
> Does that sound right?
>
> Thanks in advance,
> Judah
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CFCDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cfcdev?hl=en
-~----------~----~----~----~------~----~------~--~---