Hi Mike
The idea behind parent objects in inheritance is that parents are more "generic" or "abstract" versions of the children, rather than strictly being a collection of functions to share with the children. Another idea for you to consider - create a component called CiscoIPMessageBuilder.cfc. This would contain all of the possible functions required to build all possible messages: - setName() - addTitle(title) - addPrompt(prompt) - addMenuItem(name,url) - ... - getMessageXML() - returns the XML based on the added tags. You would need to create a new builder object each time a message was required. If needed, you could create separate components for each message type which would then use the builder to do the actual XML construction. Regards Kevan _____ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Dawson, Michael Sent: Friday, 9 May 2008 11:45 PM To: [email protected] Subject: [CFCDEV] Appropriate Use of Parent Object I have been building some services for our Cisco IP phone network. Each phone is both a web client and a web server. You interact with the phones by publishing or pushing XML via HTTP. Cisco has defined a small set of XML definitions that perform different actions on the phones. Most of the XML definitions contain the same tags (Title, Prompt, SoftKeyItems). Conversely, some tags (Text, Height, Width) are used in about half of the XML definitions. I created a CFC for each XML definition (CiscoIPPhoneText.cfc, CiscoIPPhoneMenu.cfc), but found that some methods, setTitle() and setPrompt(), were duplicated in most CFCs. So, I then created a parent CFC, CiscoIPPhoneBase.cfc. I moved setTitle() and setPrompt() to the base CFC. That seemed to be the correct thing to do. Each "child" CFC has a build() method that generates the XML packets using the getXXX() methods. Now, I have found that there are some other methods that are duplicate, but not in the majority of XML definitions: setText(), setHeight(), etc. Since those "occasional" tags appear in more than one XML definition, would it be correct to also place them in the base CFC? My thought is that the base CFC should hold every method that could be duplicated, even if only once. Is there anything wrong with what I'm doing? Below are two example XML packets that are requested by the phones. Notice there are some attributes that are common with most XML definitions. <CiscoIPPhoneText> <Title>This is the top line of the display</Title> <Prompt>This is the bottom line of the display</Prompt> <Text>This area is simple text with only line feeds, carriage returns and tabs</Text> <SoftKeyItem> <Name>Button Name 1</Name> <URL>Button Action 1</URL> <Position>Button Location 1</Position> </SoftKeyItem> <SoftKeyItem> <Name>Button Name 2</Name> <URL>Button Action 2</URL> <Position>Button Location 2</Position> </SoftKeyItem> </CiscoIPPhoneText> <CiscoIPPhoneMenu> <Title>This is the top line of the display</Title> <Prompt>This is the bottom line of the display</Prompt> <MenuItem> <Name>Display Text 1</Name> <URL>Menu URI 1</URL> </MenuItem> <MenuItem> <Name>Display Text 2</Name> <URL>Menu URI 2</URL> </MenuItem> <SoftKeyItem> <Name>Button Name</Name> <URL>Button Action</URL> <Position>Button Location</Position> </SoftKeyItem> </CiscoIPPhoneMenu> Thanks m!ke --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
