coldfusion OO programming concepts - need help!

Discussion in 'Programming' started by cf_matt, Jun 29, 2007.

  1. #1
    Hi
    At the moment i have a contact manager application i am building.
    a contact has a title (mr/mrs/miss) and can have multiple addresses, multiple telephone numbers.

    CFC's dont allow me to do multiple inheritance. I can extend to 1 component then extend to the next one in a kind of "daisy chain" but this is not ideal, if anything changes in my application there are a lot of dependencies.

    I have been told by Hal Helms to use something called aggregation but I am finding this concept difficult to grasp.

    I believe i am supposed to do something like the following see attached code:

    contactObj = createObject("component","components.contact").init("#application.settings.dsn#");
    titleObj = createObject("component","components.contact.title").init("#application.settings.dsn#");
    
    titleObj.setTitleID( form.titleID );
    
    contactObj.setTitle(titleObj);
    Code (markup):
    This seems to work fine, i have a setTitle() method in the contact.cfc which creates the title object.

    The problem is, as soon as i reference the setTitle() method from within the contact.cfc I can error saying that the return type is not of type "title"

    I think i've either got this completely wrong or i'm missing something.

    Can someone please help?
     
    cf_matt, Jun 29, 2007 IP
  2. Aztral

    Aztral Well-Known Member

    Messages:
    344
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    125
    #2
    Please copy and paste your settitle function
     
    Aztral, Jul 5, 2007 IP
  3. datropics

    datropics Peon

    Messages:
    309
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    0
    #3
    are you there? we're waiting...
     
    datropics, Jul 18, 2007 IP