Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / June 2007



Tip: Looking for answers? Try searching our database.

coldfusion OO programming

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cf_matt - 29 Jun 2007 09:50 GMT
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:

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?

My e-mail address is matt.kennedy@coastdigital.co.uk

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);
Stressed_Simon - 29 Jun 2007 12:15 GMT
You have set the type of your cfargument tag to be title, but as we can see from your attached code the path for this CFC is components.contact.title you need to change the type to that.
cf_matt - 29 Jun 2007 12:20 GMT
Brilliant Simon, thanks, i just worked it out actually that i didnt have the path in the argument like you said.

Am I doing this all correctly, is it best practice?
Stressed_Simon - 29 Jun 2007 12:45 GMT
These are the essentials of OOP with CFCs. As far as is this best practice I would have to see more of your code and your architecture.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.